AutoPostBack Event Doesnt get Fired
-
Hi guys, Im working on a Asp.net web page(VS2003 V1.1) here i have a page in which there is a textbox1 which is readonly and it gets filled up with the system date and i have another textbox2 with a calendar in it so that the user clicks the calendar and chooses the date and the textbox2 gets filled with the chosen date, Now here comes the issue i have another textbox called textbox3 which actually gets populated with the difference between the dates chosen. so i have written my difference in date calculation on the method textbox2_TextChanged and i have set the AutoPostBack function as TRUE. But after the user selects the date on textbox2 and navigates to textbox3 the autopostback event doesnt get fired but instead after all these 3 textboxes i have a radio button which when checked i have written a code whose autopostback is set true. Now when the checkbox is checked the autopostback event of textbox2 gets fired after which the autopostback event of the checkbox gets fired. On Whole the AutoPostBack event of Textbox2 gets fired only when the AutoPostBack of any other control gets fired. My friends are advising me to code the difference of the dates in JavaScript instead of coding it on the TextChanged method of the textbox. But as you see im very Weak in Javascript. Below is my code: Page.aspx
<tr>
<TD style="WIDTH: 211px; HEIGHT: 3px" width="211" height="3">Date</TD>
<TD width="70%" height="28"><asp:textbox id="txtDate" runat="server" CssClass="txtboxNormal" Width="96px" MaxLength="10"
ReadOnly="True"></asp:textbox></TD>
</tr>
<TR>
<TD style="WIDTH: 211px; HEIGHT: 34px" width="211" height="34">Date of Compliance</TD>
<TD style="HEIGHT: 34px" width="70%" height="34"><asp:textbox id="txtCompDate" runat="server" CssClass="txtboxNormal" Width="96px" MaxLength="10"
AutoPostBack="True"></asp:textbox> <IMG onclick="javascript:OpenCalendar('Date');" src="../DatePicker/calendar15.jpg" border="0"
id="IMG1" runat="server"></TD>
</TR>Javascript for the calendar on the aspx page:
function OpenCalendar(field)
{
var MyArgs = window.showModalDialog("../DatePicker/aspdatepicker.asp", "null","dialogHeight:210px;dialogWidth:180px;status:no;resizable:no;center:yes");
var myDate = new Date();
if(field == "Date")
{
document.forms[0].txtCompliedDt.value = MyArgs;
}
} -
Hi guys, Im working on a Asp.net web page(VS2003 V1.1) here i have a page in which there is a textbox1 which is readonly and it gets filled up with the system date and i have another textbox2 with a calendar in it so that the user clicks the calendar and chooses the date and the textbox2 gets filled with the chosen date, Now here comes the issue i have another textbox called textbox3 which actually gets populated with the difference between the dates chosen. so i have written my difference in date calculation on the method textbox2_TextChanged and i have set the AutoPostBack function as TRUE. But after the user selects the date on textbox2 and navigates to textbox3 the autopostback event doesnt get fired but instead after all these 3 textboxes i have a radio button which when checked i have written a code whose autopostback is set true. Now when the checkbox is checked the autopostback event of textbox2 gets fired after which the autopostback event of the checkbox gets fired. On Whole the AutoPostBack event of Textbox2 gets fired only when the AutoPostBack of any other control gets fired. My friends are advising me to code the difference of the dates in JavaScript instead of coding it on the TextChanged method of the textbox. But as you see im very Weak in Javascript. Below is my code: Page.aspx
<tr>
<TD style="WIDTH: 211px; HEIGHT: 3px" width="211" height="3">Date</TD>
<TD width="70%" height="28"><asp:textbox id="txtDate" runat="server" CssClass="txtboxNormal" Width="96px" MaxLength="10"
ReadOnly="True"></asp:textbox></TD>
</tr>
<TR>
<TD style="WIDTH: 211px; HEIGHT: 34px" width="211" height="34">Date of Compliance</TD>
<TD style="HEIGHT: 34px" width="70%" height="34"><asp:textbox id="txtCompDate" runat="server" CssClass="txtboxNormal" Width="96px" MaxLength="10"
AutoPostBack="True"></asp:textbox> <IMG onclick="javascript:OpenCalendar('Date');" src="../DatePicker/calendar15.jpg" border="0"
id="IMG1" runat="server"></TD>
</TR>Javascript for the calendar on the aspx page:
function OpenCalendar(field)
{
var MyArgs = window.showModalDialog("../DatePicker/aspdatepicker.asp", "null","dialogHeight:210px;dialogWidth:180px;status:no;resizable:no;center:yes");
var myDate = new Date();
if(field == "Date")
{
document.forms[0].txtCompliedDt.value = MyArgs;
}
}You should listen to your friends, and learn JavaScript. You cannot hope to be a serious web-developer if you don't. Posting back to the server in this scenario is the wrong approach.
-
You should listen to your friends, and learn JavaScript. You cannot hope to be a serious web-developer if you don't. Posting back to the server in this scenario is the wrong approach.
Hi.. Thanx for the reply.. well thats what i have done.. finally completed it with javascript.. but still im amazed why doesnt the logic takeplace at the text changed method of the textbox.:confused:. will investigate on it, finally have done the task. Thanx and regards, Tash..