Click here to Skip to main content
16,004,828 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Flash, Handlers, and asp.net Pin
Christian Graus12-Jun-09 11:12
protectorChristian Graus12-Jun-09 11:12 
GeneralRe: Flash, Handlers, and asp.net Pin
Acorian13-Jun-09 5:10
Acorian13-Jun-09 5:10 
Questionshowing progress in asp.net Pin
mark_me12-Jun-09 5:28
mark_me12-Jun-09 5:28 
AnswerRe: showing progress in asp.net Pin
led mike12-Jun-09 5:36
led mike12-Jun-09 5:36 
GeneralRe: showing progress in asp.net Pin
mark_me12-Jun-09 6:05
mark_me12-Jun-09 6:05 
AnswerRe: showing progress in asp.net Pin
ToddHileHoffer12-Jun-09 7:52
ToddHileHoffer12-Jun-09 7:52 
QuestionWill setting static machineKey resolve FormsAuthentication issue in web farm?? Pin
Mark Graham12-Jun-09 5:09
Mark Graham12-Jun-09 5:09 
QuestionCancel Postback of Textbox if it is blank Pin
meeram39512-Jun-09 4:01
meeram39512-Jun-09 4:01 
I have a textbox in my form which is inside an updatepanel.
The functionality is, it checks whether the UserLogin is already exists in db.
If it's there, it shows error message, otherwise no. There is also a
requiredfield validator which shows that this field is required.
These are all working fine.

My issue is whenever the text box is blank, even though the requiredfieldvalidator
displays, it suddenly went off because of the postback of text box.
Following is my code. Could anybody please help where I'm doing wrong:

 <asp:UpdatePanel ID="UserNameUpdatePanel" runat="server" UpdateMode="Conditional
">
                                    <ContentTemplate>                                       
                                        <asp:TextBox ID="UserNameTextBox" 
AutoPostBack="true" OnTextChanged="UserName_Changed" runat="server" MaxLength="50"></asp:TextBox>               
                                        <asp:Label ID ="litusername" runat="server" 
Text="*" ForeColor="Red"></asp:Label>
                                        <asp:RequiredFieldValidator ID="UserNameRequiredFieldValidator" runat="server" ErrorMessage="Required Field" 
                                            Display="Dynamic" 
ControlToValidate="UserNameTextBox" CssClass="RequiredField">
</asp:RequiredFieldValidator>
                                        <asp:Image ID="UserNameImage" 
runat="server" Visible="false" />                    
                                        <asp:Label ID="lblMessage" 
runat="server" CssClass="ErrorMessagesLabel" ></asp:Label> 
                                        <asp:RegularExpressionValidator ID="UserNameExpressionValidator" runat="server" 
ControlToValidate="UserNameTextBox"
  CssClass="RequiredField" 
ValidationExpression="[\w|]*" ErrorMessage="UserLogin Already exists"></asp:RegularExpressionValidator>               
</ContentTemplate>               
</asp:UpdatePanel>


OnTextChange Event Handler:
protected void UserName_Changed(object sender, EventArgs e)
    {
        
    Business.User u = new User();
    lblMessage.Text = "";
    UserNameImage.ImageUrl = "";
    if (UserNameTextBox.Text != "")
    {
       string strUserName = UserNameTextBox.Text.Trim();
       List<string> UserNames = u.GetUserLogin();
       if (UserNameImage.Visible == false)
          UserNameImage.Visible = true;

        if (UserNames.Contains(strUserName))
        {
            UserNameImage.ImageUrl = "~/images/unacknowledged_x.gif";
            lblMessage.Text = "User Name Already Exists";
         }
         else
         {
           UserNameImage.ImageUrl = "~/images/acknowledged_checkmark.gif";
            lblMessage.Text = "";
         }
       }
       else
       {
          UserNameRequiredFieldValidator.Visible = true;
       }
        
    }


Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.

AnswerRe: Cancel Postback of Textbox if it is blank Pin
ToddHileHoffer12-Jun-09 6:42
ToddHileHoffer12-Jun-09 6:42 
Questionhow to see controls from another page in asp.net Pin
LucBite12-Jun-09 3:56
LucBite12-Jun-09 3:56 
AnswerRe: how to see controls from another page in asp.net Pin
Colin Angus Mackay12-Jun-09 4:14
Colin Angus Mackay12-Jun-09 4:14 
General[Message Deleted] Pin
LucBite13-Jun-09 1:47
LucBite13-Jun-09 1:47 
GeneralRe: here is my scenario Collin Pin
LucBite13-Jun-09 2:03
LucBite13-Jun-09 2:03 
AnswerRe: how to see controls from another page in asp.net Pin
Vimalsoft(Pty) Ltd13-Jul-09 3:58
professionalVimalsoft(Pty) Ltd13-Jul-09 3:58 
QuestionIs it possible to kill all events for a control? Pin
thomasa12-Jun-09 3:30
thomasa12-Jun-09 3:30 
QuestionGridView - NullReferenceException Pin
ffowler12-Jun-09 2:39
ffowler12-Jun-09 2:39 
AnswerRe: GridView - NullReferenceException Pin
N a v a n e e t h12-Jun-09 2:55
N a v a n e e t h12-Jun-09 2:55 
GeneralRe: GridView - NullReferenceException Pin
ffowler12-Jun-09 3:02
ffowler12-Jun-09 3:02 
AnswerRe: GridView - NullReferenceException Pin
saanj12-Jun-09 3:02
saanj12-Jun-09 3:02 
AnswerRe: GridView - NullReferenceException Pin
Abhijit Jana12-Jun-09 3:06
professionalAbhijit Jana12-Jun-09 3:06 
QuestionTable Controls clear Pin
kanadoss12-Jun-09 2:08
kanadoss12-Jun-09 2:08 
AnswerRe: Table Controls clear Pin
saanj12-Jun-09 2:22
saanj12-Jun-09 2:22 
GeneralRe: Table Controls clear Pin
kanadoss12-Jun-09 2:33
kanadoss12-Jun-09 2:33 
GeneralRe: Table Controls clear Pin
N a v a n e e t h12-Jun-09 2:50
N a v a n e e t h12-Jun-09 2:50 
GeneralRe: Table Controls clear Pin
saanj12-Jun-09 2:53
saanj12-Jun-09 2:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.