I am using ajax calender extender to pickup date, but whenever I click on image button to popup calender, it is causing postback. I am doing as follows:
<asp:TextBox ID="txtDate" runat="server" ToolTip="Last Date" CssClass="g2"</asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" Height="26px" width="30px" ImageUrl="~/images/cal.jpg"></asp:ImageButton>
<asp:CalendarExtender ID="txtDate_CalendarExtender" runat="server"
Enabled="True" TargetControlID="txtDate" PopupButtonID ="ImageButton1"></asp:CalendarExtender>
I am confused, as I never encountered such scenerio before .
why don't you use it like this ,why are you using button for the calender extender.
<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" TargetControlID="txtStartDate" runat="server"/>
Related
I am trying to use a calendar to insert dates. Unfortunately, I have to use more than one calendar. For extracting the date from the calendar, I am using Ajax toolkit
`<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" EnableScriptGlobalization="true" EnableScriptLocalization="true" runat="server">
</cc1:ToolkitScriptManager>
<asp:TextBox ID="DateOfPurchase" runat="server" Height="30px" ReadOnly="true" Width="262px"></asp:TextBox>
<asp:ImageButton ID="imgPopup" ImageUrl="images/index.jpg" ImageAlign="Bottom"
runat="server" Height="27px" Width="37px" />
<cc1:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup" runat="server" TargetControlID="DateOfPurchase"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>`
So whenever I add more than one
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" EnableScriptGlobalization="true" EnableScriptLocalization="true" runat="server">
</cc1:ToolkitScriptManager>
my program shows error.
And if I use Only one ToolkitScriptManager and multiple Ajax calendar controls, clicking on only one image button for displaying the calendar, all the calendars,on the page, pops up.
Each CalendarExtender must have its own ID
<asp:ImageButton ID="imgPopup1" ImageUrl="images/index.jpg" ImageAlign="Bottom"
runat="server" Height="27px" Width="37px" />
<cc1:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup1" runat="server" TargetControlID="DateOfPurchase1"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>`
<asp:ImageButton ID="imgPopup2" ImageUrl="images/index.jpg" ImageAlign="Bottom"
runat="server" Height="27px" Width="37px" />
<cc1:CalendarExtender ID="Calendar2" PopupButtonID="imgPopup2" runat="server" TargetControlID="DateOfPurchase2"
Format="dd/MM/yyyy">
</cc1:CalendarExtender>`
I have calendarextender for a textbox. I need do the requiredfiled validation after lost focus. But the code below doesn't show red * after lost focus.
<asp:TextBox ID="txtDateS" runat="server" Width="80px"/>
<cc1:calendarextender ID="ceDateS" runat="server" CssClass="cal" Enabled="True" TargetControlID="txtDateS" />
<asp:RequiredFieldValidator ID="rfvDates" runat="server" ErrorMessage="RequiredFieldValidator" Text="*" ControlToValidate="txtDateS"></asp:RequiredFieldValidator>
<cc1:ValidatorCalloutExtender ID="rfvDates_ValidatorCalloutExtender" runat="server" Enabled="True" TargetControlID="rfvDates"></cc1:ValidatorCalloutExtender>
The RequiredFieldValidator doesn't fire when the control loses focus (unless you've previously entered text and then removed it), what you can try is to add the following to the page load event:
txtDateS.Attributes.Add("onblur", "ValidatorOnChange(event);")
I found, on simple form in ASP.NET page I can submit its values by pressing enter key by including form fields into Panel control and set up its default button.
But how can I do this for DetailsView? I want to submit by insert button on inserting and update button on updating.
You can try with DefaultButton property (Default Submit Button)
<asp:Panel ID="panel1" runat="server" defaultbutton="Button1">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button1" OnClick="Button1_Click" />
</asp:Panel>
Link : http://msdn.microsoft.com/fr-fr/library/system.web.ui.webcontrols.panel.defaultbutton.aspx
You can also define AccessKey property
Link : http://msdn.microsoft.com/fr-fr/library/system.web.ui.webcontrols.webcontrol.accesskey.aspx
I have a lot of textboxes on submit page and all have a validator. I want to control them with a submit button which is on master page. It works but other buttons also cause validation. validation summary is always shown either submit button is clicked or any other buttons. how can I control this situation? (asp.net)
for each individual submit use "ValidationGroup". here is the sample:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="TextBox1" ValidationGroup="Submit" ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="TextBox2" ValidationGroup="Submit" ID="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator>
<asp:Button ID="Button1" ValidationGroup="Submit" runat="server" Text="Button" />
I think you can resolve this by using ValidationGroup Property..
http://msdn.microsoft.com/en-us/library/ms227424.aspx
http://www.w3schools.com/aspnet/prop_webcontrol_imagebutton_validationgroup.asp
Thanks
Deepu
I have a modalpopupExtender which is opened when edit button is clicked.In that i have a gridview in which if click any row the popup gets hidden and the values are displayed on the page.The problem is that when i keep this code in the update panel the modalpopupextender is not getting hidden after clicking in the gridview.I have a master page in my page and using Ajax modal popup extender
are you doing a full postback? If so, in the Click event why not use ModalPopup.Hide()??
I saw the same behavior what i did was putting modelpopup before update panel that way it worked
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<cc1:ModalPopupExtender ID="mpeScreenFreez"
runat="server"
BackgroundCssClass="modalBackground"
DropShadow="true"
TargetControlID="btnDummy"
PopupControlID="panFreeze">
</cc1:ModalPopupExtender>
<asp:Panel ID="panFreeze" runat="server" CssClass="modalPopup" style="display:none;">
<asp:Label ID="lblSave" runat="server" Font-Bold="true" Text="Sending the Quote....">
</asp:Label>
</asp:Panel>
<asp:Button ID="btnDummy" runat="server" CssClass="hidden" />
<asp:UpdatePanel ID="upDirectHomOwnrPremQuote" runat="server">
<ContentTemplate></ContentTemplate>