Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello everyone,
I am stuck in a code. Please help me out. Thanks in advance.

I m trying to check the username availability from our database. I have a page having controls: a text box for email-id,text box for password and a required field validater is associated with the password box.

The problem is that when ever i click the button to check the availability, the required field validater is fired and i can not perform the desire work. Here is the code of it:
<asp:scriptmanager id="ScriptManager1" runat="server" enablepartialrendering="true" xmlns:asp="#unknown">
        </asp:scriptmanager>
        <asp:updatepanel id="UpdatePanel1" runat="server" xmlns:asp="#unknown">
            <contenttemplate>
                <table align="center" class="style1">
                    <tr>
                        <td align="left" class="style5">
                            Email ID *</td>
                        <td align="left" class="style4">
                            <asp:textbox id="txtuid" runat="server"></asp:textbox>
                        </td>
                        <td class="style8">
                            <asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server">
                    ControlToValidate="txtuid" ErrorMessage="Login ID is must" 
                    Font-Bold="True"&gt;</asp:requiredfieldvalidator>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td align="left" class="style5">
                            <asp:linkbutton id="lbtavlble" runat="server" onclick="lbtavlble_Click">Check 
                Availablity</asp:linkbutton>
                        </td>
                        <td align="left" class="style4">
                            <asp:label id="lblerror" runat="server" forecolor="Red"></asp:label>
                        </td>
                        <td class="style8">
                            &nbsp;</td>
                        <td>
                            &nbsp;</td>
                    </tr>
                </table>
            </contenttemplate>
        </asp:updatepanel>
    <table align="center" class="style1">
        <tr>
            <td align="left" class="style5">
                Password</td>
            <td align="left" class="style4">
                <asp:textbox id="txtpasword" runat="server" textmode="Password" xmlns:asp="#unknown"></asp:textbox>
            </td>
            <td class="style8">
                <asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" xmlns:asp="#unknown">
                    ControlToValidate="txtpasword" ErrorMessage="Pls Type ur Password" 
                    Font-Bold="True" Font-Italic="False"&gt;</asp:requiredfieldvalidator>
                   </td>
            <td>
                &nbsp;</td>
        </tr></table>
Posted
Updated 18-Jun-10 7:09am
v2
Comments
Sandeep Mewara 18-Jun-10 13:11pm    
You just said it's not working the desired way. Whats is the actual result right now and what is expected by you?

Hi,
you can solve this by adding ValidationGroup to your LinkButton and adding another RequiredFieldValidator with that ValidationGroup to your Eamil Id TextBox
 
Share this answer
 
Comments
i.ahmad86 21-Jun-10 1:38am    
can u explain in details...
I mean to say .. to add a required field as follows

<asp:requiredfieldvalidator id="RequiredFieldValidator3" runat="server" xmlns:asp="#unknown">
ControlToValidate="txtuid" ErrorMessage="Login ID is must" Font-Bold="True" ValidationGroup="avbl">


and update your link button as

<asp:linkbutton id="lbtavlble" runat="server" onclick="lbtavlble_Click" validationgroup="avbl" xmlns:asp="#unknown">Check Availablity
 
Share this answer
 
v2
Comments
i.ahmad86 22-Jun-10 0:12am    
the user id is not a big deal,the problem is that,when i click on the link button,the rqrd field validator for password invoked.i.e. its asking me to give a password. pls helpme out..
other wise i have to opt javascript for all these validations... :(
G Sandeep Kumar 22-Jun-10 10:38am    
yaa.. if you give validation group to your availability link button then it will not invoke other required fields, except whose validation group name matches with its own validation group ... the same modification i did in above answer... hav you gone through it ..
I had a bit of a different scenario and this didn't work for me. I did however find a solution, you can read it on my blog:
http://jeffreypaarhuis.com/2011/08/08/validation-not-working-in-updatepanel/
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900