mkazim85 0 Newbie Poster

Hello Dears

I am facing a problem and for solving this i visit number of forums but not successful to find my solution. The scienario is that I have a gridview and it provides the functionality of add, edit, update and delele of Departments. I open a modal pop up extender for add and edit Department. When I open modal pop up for add or edit and fill all the mandatory fields and press submit button and then click anything on form that can postback on server, it is postback, but if i do not fill the mandatory field press submit button, validators called properly, then i press cancel button form is closed and now if i press any button on form first time it is not postback but if i press it on second time it postback perfectly. I write a client side javascript function on targetcontrol , it is called perfectly. I do not know why the the forms buttons did not postback first time and why theyt postback second time . I have also attached the validationgroup property with each control.

Here is my code


ASPX Code

border-width: 3px; border-style: solid; border-color: Gray; padding: 3px;"


<asp:Panel ID="pnlDepartment" runat="server" Style="display: none; background-color: #ffffdd; Height="150px"


Width="483px">


<table style="width: 100%">


<tr>


<td style="width: 41px">


&nbsp;


</td>


<td colspan="2">


<asp:Label ID="lblEditDepartment" runat="server"></asp:Label>


</td>


</tr>


<tr>


<td style="width: 41px">


&nbsp;


</td>


<td colspan="2">


<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtDepartmentName"


ErrorMessage="Please enter Department Name" Display="None" ValidationGroup="Submit"></asp:RequiredFieldValidator>


<ajaxToolkit:ValidatorCalloutExtender ID="RequiredFieldValidator1_ValidatorCalloutExtender"


runat="server" TargetControlID="RequiredFieldValidator1" BehaviorID="textValidator"


Enabled="True">


</ajaxToolkit:ValidatorCalloutExtender>


</td>


</tr>


<tr>


<td style="width: 41px">


&nbsp;


</td>


<td style="width: 117px">


<asp:Label ID="lblDept" runat="server" Text="Department Name"></asp:Label>


</td>


<td style="width: 127px">


<asp:TextBox ID="txtDepartmentName" runat="server" ValidationGroup="Submit"></asp:TextBox>


</td>


</tr>


<tr>


<td style="width: 41px">


&nbsp;


</td>


<td style="width: 117px">


&nbsp;


</td>


<td style="width: 127px">


<asp:Button ID="btnSave" runat="server" Text="Save" ValidationGroup="Submit" OnClientClick="return ClosePopup();"


OnClick="btnSave_Click" />


&nbsp;&nbsp;


<asp:Button ID="btnCancel" runat="server" Text="Cancel" />


</td>


</tr>


<tr>


<td style="width: 41px">


&nbsp;


</td>


<td style="width: 117px">


&nbsp;


</td>


<td style="width: 127px">


</td>


</tr>


</table>


</asp:Panel>


<asp:Button ID="btnShowPopup" runat="server" Style="display: none" />


<ajaxToolkit:ModalPopupExtender ID="mdlPopupAdd" runat="server" TargetControlID="btnHidden"


PopupControlID="pnlDepartment" CancelControlID="btnCancel" BackgroundCssClass="modalBackground"


BehaviorID="modalwithinput" OnCancelScript="CancelClosePopup()">

<ajaxToolkit:ModalPopupExtender>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.