Hey all
I have a form with update panel, Drp Down and Text boxes and requered Field Validators.There is also a button that do post backs.

Validation group of Field Validators and button are same.

When page loads and i submit data validators appear. After i select data or change values in DDL using Ajax validators are not shown and takes me to other page as well without selecting mandatory fields.

Will somebody tell me what actually problem is?????

Recommended Answers

All 8 Replies

Hey all
I have a form with update panel, Drp Down and Text boxes and requered Field Validators.There is also a button that do post backs.

Validation group of Field Validators and button are same.

When page loads and i submit data validators appear. After i select data or change values in DDL using Ajax validators are not shown and takes me to other page as well without selecting mandatory fields.

Will somebody tell me what actually problem is?????

Can you please post some line of code ? so it will be easy to identify what's causing the problem ?
Also did you set the InitialValue property of RequireField validator because if you are using DDL then you must have to set it.
Thanks !
Rohan

Yes i have set Initial value property of DDL's to 0.
Below are my line of code.

<tr>
           <td colspan="8" valign="top">
         <asp:UpdatePanel id="UpdatePanel1" runat="server">
         <contenttemplate>
								
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
								    
									
	<tr>
	<td colspan="8" valign="top" class="contentborder">
                                          
	<table width="100%" border="0" cellpadding="0" cellspacing="0">
	<tr>
	<td align="right" style="width: 115px;vertical-align:middle;">
	<asp:Label ID="lblAutoType" runat="server" CssClass="contentborderText">Auto Type *&nbsp;</asp:Label>
	</td>
	<td align="left" style="vertical-align:middle;" >
	<asp:DropDownList ID="ddlAutoType" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlAutoType_SelectedIndexChanged"
	 Width="170px" Font-Bold="True">
	</asp:DropDownList><asp:RequiredFieldValidator ID="RequiredFieldValidator14" runat="server" ControlToValidate="ddlAutoType"
	ErrorMessage="Select Auto type" Font-Size="X-Large" InitialValue="0" ValidationGroup="vgsellcar">*</asp:RequiredFieldValidator></td>
	<td align="right" style="vertical-align:middle;">
	Price*</td>
	<td align="left" style="vertical-align:middle;">
	<asp:TextBox ID="txtPrice" runat="server"  Width="168px" Font-Bold="True" TabIndex="4"></asp:TextBox><asp:RequiredFieldValidator
	ID="RequiredFieldValidator4" runat="server" ControlToValidate="txtPrice" ErrorMessage="Enter Price"
	Font-Size="X-Large" ValidationGroup="vgsellcar">*</asp:RequiredFieldValidator><asp:RegularExpressionValidator
	ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtPrice" ErrorMessage="Enter valid Price"
	Font-Size="X-Large" ValidationExpression="^(?=.*[1-9].*$)\d{0,7}(?:\.\d{0,9})?$"
	ValidationGroup="vgsellcar">*</asp:RegularExpressionValidator></td>
	</tr>


	<tr >
	<td align="right" style="vertical-align:middle;">
	<asp:Label ID="lblDerivative" runat="server" CssClass="contentborderText" Text=" Derivative"></asp:Label>
	&nbsp;</td>
	<td align="left" style="vertical-align:middle;">
	<asp:DropDownList ID="ddlDerivative" runat="server"
	Width="170px" TabIndex="3">
	</asp:DropDownList></td>
	<td align="right" style="vertical-align:middle;">
	<asp:Label ID="lblBodyType" runat="server" CssClass="contentborderText" Text="Body Type*"></asp:Label></td>
	<td align="left" style="vertical-align:middle;">
	<asp:DropDownList ID="ddlBodyType" runat="server" CssClass="contentborderText" AutoPostBack="false" 
	Width="170px" Font-Bold="True" TabIndex="7">
	</asp:DropDownList><asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server"
	ControlToValidate="ddlbodytype" ErrorMessage="Select Body Type" Font-Size="X-Large"
	InitialValue="0" ValidationGroup="vgsellcar">*</asp:RequiredFieldValidator></td>
	</tr>

</table>
									
	</contenttemplate>
         </asp:UpdatePanel>
         </td>
         </tr>

	<tr>
	<td colspan="8" align=center>
	<asp:Button ID="btnSubmit" runat="server" CssClass="submitButton" 
	Text="Submit & Continue"  ValidationGroup="vgsellcar"
	Width="160px"   />
	</td>
        </tr>

keep your button in content template it will work.

or register button's event with update panel's trigger.

from where you are filling your drop down with value ? is the value coming from database ? i have added some static value using <asp:ListItem> and it's working as expected. see the below code.

<asp:DropDownList ID="ddlAutoType" runat="server" AutoPostBack="True" Width="170px" Font-Bold="True" OnSelectedIndexChanged="ddlAutoType_SelectedIndexChanged">
<asp:ListItem Value="0">------Select------</asp:ListItem>
<asp:ListItem Value="1">Test1</asp:ListItem>
<asp:ListItem Value="2">Test2</asp:ListItem>
</asp:DropDownList>

Drop Downs are populated from database.
I aslo include button in content template but it still not works :(
Its my first time using update panel: will you please tell me what do you mean by registering buttons event with update panel trigger ?

1>Your Dropdown must be in update panel and submit button outside update panel .
2>There must be some issue with the postback property of the dropdown box.

Let me know if you need more help.

In the above code drop downs are in update panel and submit button outside it. also AutoPostBack property of drop downs are set ture.

In the above code drop downs are in update panel and submit button outside it. also AutoPostBack property of drop downs are set ture.

after populating drop down with data from database , what the value in drop down at index [0], it's like "---Select----" ?

Regarding registering Trigger, you can try by this way also. you can define trigger after completing <ContentTemplate></ContentTemplate>
There are two types of trigger supported PostBackTrigger and AsyncPostBackTrigger. See the below line of code:
<Triggers>
<asp:PostBackTrigger ControlID="ur control id" />
</Triggers>

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.