Have to click button twice before event will fire!

Last post 02-12-2008 2:02 AM by abksharma. 5 replies.

Sort Posts:

  • Have to click button twice before event will fire!

    01-28-2008, 12:43 PM
    • Member
      245 point Member
    • sls29
    • Member since 03-22-2004, 4:48 PM
    • Posts 57

    Hi,

    I have a really weird (or it is to me!) problem that I cannot seem to figure out. I am doing a simple login that goes through a sql db. I have two textboxes, and an ImageButton inside of an Update Panel. When I click the button though to login, it never works the first time. It clears the text out of the password textbox, and then I have to click the button again for it to work!

    From some other posts that I have seen, I tried the following things:

    1) Setting AutoEventWireUp="false"

    2) Make sure the Textbox does not have AutoPostBack set to true.

    3) Make sure the ImageButton is not moving.

     

    Does anyone have any ideas? It ALWAYS works the second time, and does absolutely nothing the first time....I would appreciate any help, as this problem is driving me crazy!!

    Thanks!

    Subhash 

    Thanks,
    Subhash

    Please remember to 'Mark as Answer' if this post answered your question!
  • Re: Have to click button twice before event will fire!

    01-28-2008, 12:51 PM
    • Star
      13,860 point Star
    • kipo
    • Member since 07-20-2006, 7:10 AM
    • Croatia
    • Posts 2,374

    Can you post your code?

  • Re: Have to click button twice before event will fire!

    01-29-2008, 8:21 PM
    • Member
      245 point Member
    • sls29
    • Member since 03-22-2004, 4:48 PM
    • Posts 57

    Hi kipo,

    Thanks for your reply. My code is below. I would really appreciate any help!

     


    Thanks,
    Subhash

    Please remember to 'Mark as Answer' if this post answered your question!
    Filed under:
  • Re: Have to click button twice before event will fire!

    01-29-2008, 8:23 PM
    • Member
      245 point Member
    • sls29
    • Member since 03-22-2004, 4:48 PM
    • Posts 57

    Let me try that again....

     

    <%@ Page Language="C#" AutoEventWireup="false" CodeFile="MyProfile.aspx.cs" Inherits="MyProfile" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        Namespace="System.Web.UI" TagPrefix="asp" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Page Title</title>
        <link href="styles.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
            </asp:ScriptManager>
           
            <cc1:AnimationExtender ID="loginAnimation" TargetControlID="upLogin" runat="server">
            <Animations>
                <OnLoad>
                    <Sequence>
                        <Parallel Duration="0.3">
                            <StyleAction AnimationTarget="loginForm" Attribute="display" value="block"></StyleAction>
                            <StyleAction AnimationTarget="getStartedImg" Attribute="display" value="block"></StyleAction>
                            <StyleAction AnimationTarget="getStartedText" Attribute="display" value="block"></StyleAction>
                        </Parallel>
                        <Parallel>
                            <FadeIn AnimationTarget="loginForm" Duration="0.5"></FadeIn>
                            <FadeIn AnimationTarget="getStartedImg" Duration="0.5"></FadeIn>
                        </Parallel>
                    </Sequence>
                </OnLoad>
            </Animations>
            </cc1:AnimationExtender>
           
         
        <div id = "container">
       
            <div id = "flashMovie">
       
                <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,79,0"
                id="mainMovie"
                width="625" height="90">
                  <param name="movie" value="media/mainMovie.swf">
                  <param name="bgcolor" value="#012561">
                  <param name="quality" value="high">
                  <param name="allowscriptaccess" value="samedomain">
                 
                  <embed type="application/x-shockwave-flash"
                   pluginspage="http://www.macromedia.com/go/getflashplayer"
                   name="mainMovie"
                   width="625" height="90"
                   src="media/mainMovie.swf"
                   bgcolor="#012561"
                   quality="high"
                   swliveconnect="true"
                   allowscriptaccess="samedomain">
                  
                    <noembed>
                    </noembed>
                  </embed>
               
                </object>
            </div>
           
            <div id = "navbar">
                <img src="images/navbar.jpg" />
            </div>
           
        
           
            <div id = "content">
           
           
          
                <div id = "mainContent" style="position:absolute; top:25px; left:0px; margin-left:25px;">
                   
                    <div id = "loginForm" style="background-image:url(images/loginBk.gif); position:absolute; display:none; top:1px; left:0px; font-family:Calibri; font-size:11pt; color:White; width:300px; height:200px; border:solid 1px black">
                   
                             
                    <asp:UpdatePanel ID="upLogin" runat="server" UpdateMode="Conditional">
                        <ContentTemplate>
                            <p align="center" style="color:White; font-weight:normal; border-bottom:solid 1px white; font-size:11pt; font-family:Calibri">
                                Already have a Profile? Login Below
                            </p>
                            <p align="right" style="position:absolute; right:50px;">
                            Username: <asp:TextBox ID="tbUserName" runat="server" AutoPostBack="false"></asp:TextBox><br />
                            Password: <asp:TextBox ID="tbPassword" runat="server" TextMode="Password" AutoPostBack="false"></asp:TextBox><br /><br />
                           
                            <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="images/login.gif" OnClick="ImageButton1_Click" /><br />
                           
                           
                            <asp:Label ID="loggedIn" runat="server" Text=""></asp:Label>
                           
                            </p>
                        </ContentTemplate>
                        <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="ImageButton1" EventName="Click" />
                        </Triggers>
                        </asp:UpdatePanel>
                       
                        <asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="upLogin">
                        <ProgressTemplate>
                        done...
                        </ProgressTemplate>
                        </asp:UpdateProgress>   
                    </div>               
                   
                    <div id = "getStartedText" style="position:absolute; display:none; top:225px; left:0px; font-family:Calibri; font-size:12pt; color:Black; width:775px">
                    <p style="line-height:1.5em">
                    <span style="font-size:18pt; text-decoration:underline; line-height:1.2em">
                    Get Started Now >><br />
                    </span>
                    Lots and lots of text.
                  
                    </p>
                    </div>
                    <div id = "getStartedImg" style="position:absolute; display:none; top:25px; left:400px; font-family:Calibri; font-size:12pt; color:black">
                        <img style="border:solid 1px black" src="images/getStarted.gif" width="350" height="150" border="0" alt="" usemap="#getStarted_Map">
                        <map name="getStarted_Map">
                        <area shape="rect" alt="Register" coords="40,84,309,122" href="Register.aspx?flg=N" target="_self">
                        </map>
                    </div>  
                </div>
                <br />
               
                <div id = "adBar">
                </div>
               
            </div>
       
        </div>
        </div>
        </form>
    </body>
    </html>
     

    Thanks,
    Subhash

    Please remember to 'Mark as Answer' if this post answered your question!
  • Re: Have to click button twice before event will fire!

    01-31-2008, 11:48 AM
    Answer
    • Member
      245 point Member
    • sls29
    • Member since 03-22-2004, 4:48 PM
    • Posts 57

    I was able to figure out the problem. There was a problem in my code-behind that I did not catch.

    Thanks to everyone who looked at this!


     

    Thanks,
    Subhash

    Please remember to 'Mark as Answer' if this post answered your question!
  • Re: Have to click button twice before event will fire!

    02-12-2008, 2:02 AM
    • Member
      4 point Member
    • abksharma
    • Member since 02-12-2008, 1:54 AM
    • Posts 4
    actually I tried to see the code behind but it did not help...when I click the button for the first time it does a post back and page load is called at server. but at the second time the control stays at client and client event is called....after that for all times it stays at client side. Properties of my image button.. click opens a window at client with some navigate URL-->I am appling a javascript function to open the window at server on the button by adding attributes.... PLEASE HELP ME.... grdCompanyCard.Columns[0].Visible = true; for (int i = 0; i < grdCompanyCard.Items.Count; i++) { //getting img template from the rad grid ImageButton imgCC = grdCompanyCard.Items[i].FindControl("ImageButtonCompanyCard") as ImageButton; //getting table values of tacho smart card ID string value = dsSiteDetails.Tables[0].Rows[i]["lTachoSmartCardID"].ToString(); //setting up the tooltip imgCC.ToolTip = sClickDetails.ToString(); //the navigate url of radwindow string NavigateUrl = "CompanyCard.aspx?TachID=" + value + "&SiteID=" + m_iSiteID.ToString() + "&Status=0"; //company card id, site id and rowindex are added to function calls string str = "return OpenWindowX('" + value + "', '" + m_iSiteID.ToString() + "', '" + i + "');"; imgCC.Attributes["onclick"] = str; //AutoEventWireUp="false" } I am new to programming...2 months in .net. and 4 month in s/w field...just out of college...
Page 1 of 1 (6 items)