Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Jan 19, 2013 07:01 AM by atul2430
Member
145 Points
591 Posts
Jan 17, 2013 03:49 AM|LINK
hi all,
good morning. i am working on magzine tracking system using c#.
i have three checkbaox button subscription of magzine 1year 2 year 3 year
and subscription date : in dropdown list in month drop down list current and in year dropdown current year should be show.
my problem is i need to calculate expiry date based on subscription year(check box) and date(drop down list).
if user chek subscription for 1 year tthen in expiry label mont and year should be show.
ex: for one year sub and date 1 jan 2013 the expiry should be: 1 dec 2013.
please help me how this i do using jquery and java script.
Contributor
6129 Points
1172 Posts
Jan 17, 2013 05:08 AM|LINK
why dont you use client side script for this you can download the demo progrma from given link program name is "ListPopulateJSON"
"JsonListHandel"
https://skydrive.live.com/#cid=2F22272220E37707&id=2F22272220E37707%21103
i hope it will help alot
if you are still facing problem then email me ssohail@sunbonn.com
Jan 17, 2013 06:53 AM|LINK
Hi sohail thanks for the link.
but i didnt get. how to avoid post back while changing checkbox and dropdownlist.
plz help me
Jan 17, 2013 07:38 AM|LINK
ok send me a blank email i will provide you complete soultion after my job hours
Jan 17, 2013 11:18 AM|LINK
thanks
i have sent you mail. with attached aspx pages
All-Star
30184 Points
4906 Posts
Jan 18, 2013 03:11 AM|LINK
Hi,
Try this-
http://jsfiddle.net/asteranup/XnqbM/
Jan 18, 2013 04:14 AM|LINK
hey anup,
thanks dear i am very close to my ans.plz tell me where i need to add this java script code and how.
i already calculate date
i have check boxes insted of radio button and month will be i minus
ex: as i take date for one year is 17-jan-2013 then exp will 17-dec-2013
if i choose 1 feb 2013 then date will be 1 jan 2014. also change expiry date on change of dropdown list.
and plz tell me how to use JSfiddle which u use. waiting for ur reply.
protected void cb1year_CheckedChanged(object sender, EventArgs e) { no = 1; CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); ; } protected void cb2year_CheckedChanged(object sender, EventArgs e) { if (cb2year.Checked) { no = 2; CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); ; } } protected void cb3year_CheckedChanged(object sender, EventArgs e) { if (cb3year.Checked) { no = 3; CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); ; } } protected void cballyear_CheckedChanged(object sender, EventArgs e) { if (cballyear.Checked) { no = 10; CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); ; } } protected void ddlfsmonth_SelectedIndexChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); } protected void ddlFSYear_SelectedIndexChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); } //research Journal expiry date display //// protected void ddlrjmonth_SelectedIndexChanged1(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); } protected void ddlrjyear_SelectedIndexChanged1(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); } protected void Rcb1year_CheckedChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); ; } protected void Rcb2year_CheckedChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); ; } protected void Rcb3year_CheckedChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); ; } protected void Rcballyear_CheckedChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); ; } static DateTime dt; private DateTime CalculateDate(int monthno, int yearno) { monthno=monthno+1; if (monthno == 1) { monthno = 12; yearno = yearno+ no - 1; } else { monthno = monthno-1; yearno = yearno + no; } dt = new DateTime(yearno, monthno, 1); lblrsexp.Text = dt.ToString("MMMM-yyyy"); ; return dt; }
Jan 18, 2013 04:40 AM|LINK
Check this code-
http://jsfiddle.net/asteranup/XnqbM/4/
Change selector for radio button to checkbox. And remove all the serverside code.
Jan 18, 2013 05:25 AM|LINK
hello anup hertly thanks to you for this code.
i think this que is very easy but i am freshers and dont know how to use jquery.
where i add this js and
how to use this jsfillde
Jan 18, 2013 05:39 AM|LINK
Hey anup,
this is not working for asp standerder control
<asp:CheckBox ID="cb1year" runat="server">
atul2430
Member
145 Points
591 Posts
jquery for avoid postback
Jan 17, 2013 03:49 AM|LINK
hi all,
good morning. i am working on magzine tracking system using c#.
i have three checkbaox button subscription of magzine 1year 2 year 3 year
and subscription date : in dropdown list in month drop down list current and in year dropdown current year should be show.
my problem is i need to calculate expiry date based on subscription year(check box) and date(drop down list).
if user chek subscription for 1 year tthen in expiry label mont and year should be show.
ex: for one year sub and date 1 jan 2013 the expiry should be: 1 dec 2013.
please help me how this i do using jquery and java script.
SohailShaikh
Contributor
6129 Points
1172 Posts
Re: jquery for avoid postback
Jan 17, 2013 05:08 AM|LINK
why dont you use client side script for this you can download the demo progrma from given link program name is "ListPopulateJSON"
"JsonListHandel"
https://skydrive.live.com/#cid=2F22272220E37707&id=2F22272220E37707%21103
i hope it will help alot
if you are still facing problem then email me ssohail@sunbonn.com
Sohail Shaikh
atul2430
Member
145 Points
591 Posts
Re: jquery for avoid postback
Jan 17, 2013 06:53 AM|LINK
Hi sohail thanks for the link.
but i didnt get. how to avoid post back while changing checkbox and dropdownlist.
plz help me
SohailShaikh
Contributor
6129 Points
1172 Posts
Re: jquery for avoid postback
Jan 17, 2013 07:38 AM|LINK
ok send me a blank email i will provide you complete soultion after my job hours
Sohail Shaikh
atul2430
Member
145 Points
591 Posts
Re: jquery for avoid postback
Jan 17, 2013 11:18 AM|LINK
thanks
i have sent you mail. with attached aspx pages
asteranup
All-Star
30184 Points
4906 Posts
Re: jquery for avoid postback
Jan 18, 2013 03:11 AM|LINK
Hi,
Try this-
http://jsfiddle.net/asteranup/XnqbM/
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
atul2430
Member
145 Points
591 Posts
Re: jquery for avoid postback
Jan 18, 2013 04:14 AM|LINK
hey anup,
thanks dear i am very close to my ans.plz tell me where i need to add this java script code and how.
i already calculate date
i have check boxes insted of radio button and month will be i minus
ex: as i take date for one year is 17-jan-2013 then exp will 17-dec-2013
if i choose 1 feb 2013 then date will be 1 jan 2014. also change expiry date on change of dropdown list.
and plz tell me how to use JSfiddle which u use. waiting for ur reply.
protected void cb1year_CheckedChanged(object sender, EventArgs e) { no = 1; CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); ; } protected void cb2year_CheckedChanged(object sender, EventArgs e) { if (cb2year.Checked) { no = 2; CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); ; } } protected void cb3year_CheckedChanged(object sender, EventArgs e) { if (cb3year.Checked) { no = 3; CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); ; } } protected void cballyear_CheckedChanged(object sender, EventArgs e) { if (cballyear.Checked) { no = 10; CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); ; } } protected void ddlfsmonth_SelectedIndexChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); } protected void ddlFSYear_SelectedIndexChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlfsmonth.SelectedIndex), Convert.ToInt32(ddlFSYear.SelectedValue)); LblFSmonth.Text = dt.ToString("MMMM-yyyy"); } //research Journal expiry date display //// protected void ddlrjmonth_SelectedIndexChanged1(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); } protected void ddlrjyear_SelectedIndexChanged1(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); } protected void Rcb1year_CheckedChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); ; } protected void Rcb2year_CheckedChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); ; } protected void Rcb3year_CheckedChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); ; } protected void Rcballyear_CheckedChanged(object sender, EventArgs e) { CalculateDate(Convert.ToInt32(ddlrjmonth.SelectedIndex), Convert.ToInt32(ddlrjyear.SelectedValue)); //lblrsexp.Text = dt.ToString("MMMM-yyyy"); ; } static DateTime dt; private DateTime CalculateDate(int monthno, int yearno) { monthno=monthno+1; if (monthno == 1) { monthno = 12; yearno = yearno+ no - 1; } else { monthno = monthno-1; yearno = yearno + no; } dt = new DateTime(yearno, monthno, 1); lblrsexp.Text = dt.ToString("MMMM-yyyy"); ; return dt; }asteranup
All-Star
30184 Points
4906 Posts
Re: jquery for avoid postback
Jan 18, 2013 04:40 AM|LINK
Hi,
Check this code-
http://jsfiddle.net/asteranup/XnqbM/4/
Change selector for radio button to checkbox. And remove all the serverside code.
Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog
atul2430
Member
145 Points
591 Posts
Re: jquery for avoid postback
Jan 18, 2013 05:25 AM|LINK
hello anup hertly thanks to you for this code.
i think this que is very easy but i am freshers and dont know how to use jquery.
where i add this js and
how to use this jsfillde
atul2430
Member
145 Points
591 Posts
Re: jquery for avoid postback
Jan 18, 2013 05:39 AM|LINK
Hey anup,
this is not working for asp standerder control
<asp:CheckBox ID="cb1year" runat="server">