how to set the button visibility to false?

Last post 05-09-2008 5:23 PM by jrahma. 6 replies.

Sort Posts:

  • how to set the button visibility to false?

    05-05-2008, 5:21 PM
    • Loading...
    • jrahma
    • Joined on 06-26-2002, 4:51 AM
    • Manama
    • Posts 175

     

    I am trying to add an UpdateProgress to my page and i want to set the btnSignin button's visible to false when the user click on it. I placed the button in an UpdatePanel and addted btnSignin.Visible = false to the btnSignIn_Click even but it's not working though the UpdateProgress works fine.

     

    what can I do?

  • Re: how to set the button visibility to false?

    05-05-2008, 6:04 PM
    • Loading...
    • johram
    • Joined on 06-13-2006, 6:36 AM
    • Sweden
    • Posts 1,965
    • Moderator

    What if you put a breakpoint in the click event? Does it ever get called?

    If UpdateMode of your update panel is set to conditional then you must manually do a call to Update() on that UpdatePanel within the click method.

    If this post was useful to you, please mark it as answer. Thank you!
  • Re: how to set the button visibility to false?

    05-05-2008, 6:19 PM
    • Loading...
    • jrahma
    • Joined on 06-26-2002, 4:51 AM
    • Manama
    • Posts 175

    UpdateMode is setto Alwyas

  • Re: how to set the button visibility to false?

    05-05-2008, 11:19 PM

    Add thsi code in Page_Load event

    CommentButton.Attributes.Add(“onclick”, ” this.disabled = true; “ + ClientScript.GetPostBackEventReference(CommentButton, null) + “;”);

    http://discuss.fogcreek.com/dotnetquestions/default.asp?cmd=show&ixPost=3592

    http://blog.falafel.com/2007/11/06/CreateASubmitButtonThatPreventsDoubleClicks.aspx

    http://disturbedbuddha.wordpress.com/2007/12/10/disabling-a-trigger-control-during-asynchronous-postback/

    Chetan Sarode
    Software Engineer,
    Approva Systems Pvt Ltd,
    Pune, India.
  • Re: how to set the button visibility to false?

    05-06-2008, 12:38 AM
    Answer
    • Loading...
    • krishnav
    • Joined on 05-01-2008, 9:45 AM
    • Vijayawada
    • Posts 57

    Then try with this...

    btnSignIn.Attributes.Add("style","display:none");

    in button click event... i think it will work fine..

  • Re: how to set the button visibility to false?

    05-06-2008, 4:45 AM
    • Loading...
    • jrahma
    • Joined on 06-26-2002, 4:51 AM
    • Manama
    • Posts 175

     

    i tried both solutions but didn't work. here is my code:

     

        protected void btnSignin_Click(object sender, EventArgs e)
        {
            txtIDNumber.BorderStyle = BorderStyle.None;
            txtIDNumber.ForeColor = System.Drawing.Color.Red;
            txtIDNumber.ReadOnly = true;
            
            txtPassword.BorderStyle = BorderStyle.None;
            txtPassword.ForeColor = System.Drawing.Color.Red;
            txtPassword.ReadOnly = true;
    
            rowButtons.Visible = false;
    
            sql_connection = new SqlConnection("Data Source=.\\SQLEXPRESS;initial catalog=ahlanbahrain.com;integrated security=true");
            // sql_connection = new SqlConnection(ConfigurationManager.ConnectionStrings["website_connectionstring"].ToString());
            sql_connection.Open();
    
            sql_command = new SqlCommand("sp_get_member_profile", sql_connection);
            sql_command.CommandType = CommandType.StoredProcedure;
    
            sql_command.Parameters.Add("@member_cpr", SqlDbType.VarChar).Value = txtIDNumber.Text;
            sql_command.Parameters.Add("@member_password", SqlDbType.VarChar).Value = txtPassword.Text.ToLower();
    
            // SqlParameter retrun_cpr = new SqlParameter("@member_cpr", SqlDbType.VarChar);
            // retrun_cpr.Direction = ParameterDirection.ReturnValue;
    
            // SqlParameter retrun_email = new SqlParameter("@member_email", SqlDbType.VarChar);
            // retrun_email.Direction = ParameterDirection.ReturnValue;
    
            // SqlParameter retrun_password = new SqlParameter("@member_password", SqlDbType.VarChar);
            // retrun_password.Direction = ParameterDirection.ReturnValue;
    
            sql_reader = sql_command.ExecuteReader();
    
            if (sql_reader.Read())
            {
                // while (sql_reader.Read())
                // {
                    Application["member_cpr"] = sql_reader["member_cpr"].ToString();
                    Application["member_email"] = sql_reader["member_email"].ToString();
                    Application["member_password"] = sql_reader["member_password"].ToString();
    
                    Application["member_is_loggedon"] = true;
    
                    sql_connection.Close();
    
                    Response.Redirect("member.aspx");
                // }
            }
            else
            {
                Application["member_is_loggedon"] = false;
    
                Application["message_title"] = "نأسف!!";
                Application["message_text"] = "لم يتم العثور على حسابك الخاص بالبيانات التي ذكرتها. يرجى الضغط على زر الرجوع للتأكد من بياناتك.!!";
                Application["link_1_text"] = "الصفحة الرئيسية";
                Application["link_1_url"] = "Default.aspx";
                Application["link_2_text"] = "اتصل بنا";
                Application["link_2_url"] = "contact.aspx";
    
                Response.Redirect("message.aspx?id=" + txtIDNumber.Text + "&cc=" + txtPassword.Text);
            }
        }
    
      

     

    and this is my ASPX:

     

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="signin.aspx.cs" Inherits="signin" %>
    <%@ Register TagPrefix="ucl" TagName="ucl_website_header" Src="~/website_header.ascx" %>
    <%@ Register TagPrefix="ucl" TagName="ucl_website_menu" Src="~/website_menu.ascx" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html id="Html1" xmlns="http://www.w3.org/1999/xhtml" runat="server" dir="rtl" lang="ar-bh" >
    <head id="Head1" runat="server" dir="rtl" lang="ar-bh">
        <meta name="robots" content="INDEX,FOLLOW" />
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
        <link href="website_stylesheet.css" rel="Stylesheet" type="text/css"/>
        <meta name="keywords" content="Jassim Rahma, AlRahma, جاسم رحمة, جاسم آل رحمة, البحرين, الشيعة, آل خليفة, السياسة, الإعلام, الصحة, آل رحمة" />
        <title>AhlanBahrain.com - sign in</title>
    </head>
    <body id="Body1" runat="server" dir="rtl" lang="ar-bh" style="margin: 5" >
        <form id="form1" runat="server">
        <div>
            <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
            <asp:Table ID="Table1" runat="server" Width="779" HorizontalAlign="Center" BorderStyle="None" CellPadding="0" CellSpacing="0">
                <asp:TableRow><asp:TableCell Width="100%"><ucl:ucl_website_header ID="website_header" runat="server" /></asp:TableCell></asp:TableRow>
                <asp:TableRow><asp:TableCell Width="100%"><ucl:ucl_website_menu ID="Ucl_website_menu" runat="server" /></asp:TableCell></asp:TableRow>
                <asp:TableRow>
                <asp:TableCell Width="100%">
                    <asp:UpdatePanel ID="updatepanelSignin" UpdateMode="Always" runat="server">
                    <ContentTemplate>
                    <asp:Table ID="Table3" runat="server" HorizontalAlign="Center" BorderStyle="None" CellPadding="0" CellSpacing="0">
                        <asp:TableRow ID="TableRow1"><asp:TableCell ColumnSpan="3"><strong>الدخول إلى صفحتك الخاصة:</strong><br /></asp:TableCell></asp:TableRow>
                        <asp:TableRow ID="rowError" Visible="false"><asp:TableCell ColumnSpan="3"><br /><asp:Label runat="server" ID="lblError" Font-Bold="true" ForeColor="Red"></asp:Label><br /></asp:TableCell></asp:TableRow>
                        <asp:TableRow><asp:TableCell ColumnSpan="3"><br /></asp:TableCell></asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell HorizontalAlign="Right" VerticalAlign="Top">الرقم الشخصي</asp:TableCell>
                            <asp:TableCell HorizontalAlign="Right" VerticalAlign="Top">  :  </asp:TableCell>
                            <asp:TableCell HorizontalAlign="Right" VerticalAlign="Top"><div dir="ltr"><asp:TextBox runat="server" TextMode="SingleLine" ID="txtIDNumber" MaxLength="9" Width="200"></asp:TextBox></div></asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow><asp:TableCell ColumnSpan="3"><br /></asp:TableCell></asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell HorizontalAlign="Right" VerticalAlign="Top">كلمة السر</asp:TableCell>
                            <asp:TableCell HorizontalAlign="Right" VerticalAlign="Top">  :  </asp:TableCell>
                            <asp:TableCell HorizontalAlign="Right" VerticalAlign="Top"><div dir="ltr"><asp:TextBox runat="server" TextMode="Password" ID="txtPassword" MaxLength="12" Width="200"></asp:TextBox></div></asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow><asp:TableCell ColumnSpan="3"><br /></asp:TableCell></asp:TableRow>
                        <asp:TableRow ID="rowButtons">
                            <asp:TableCell HorizontalAlign="Center" ColumnSpan="3" VerticalAlign="Top">
                                <asp:Button runat="server" ID="btnSignin" Text=" دخول " Width="100" OnClick="btnSignin_Click" />    <asp:Button runat="server" ID="btnSignup" Text=" مشترك جديد " Width="100" PostBackUrl="~/signup.aspx" />
                            </asp:TableCell>
                        </asp:TableRow>
                        <asp:TableRow>
                            <asp:TableCell HorizontalAlign="Center" VerticalAlign="Middle" ColumnSpan="3">
                                <asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID="updatepanelSignin" runat="server">
                                <ProgressTemplate>
                                    <asp:Image ID="Image1" runat="server" ImageUrl="~/images/loading_progress.gif" />
                                </ProgressTemplate>
                                </asp:UpdateProgress>
                            </asp:TableCell>
                        </asp:TableRow>
                    </asp:Table>
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnSignin" EventName="Click" />
                    </Triggers>
                    </asp:UpdatePanel>
                </asp:TableCell>
                </asp:TableRow>
            </asp:Table>
        </div>
        </form>
    </body>
    </html>
    
     

     

     

  • Re: how to set the button visibility to false?

    05-09-2008, 5:23 PM
    • Loading...
    • jrahma
    • Joined on 06-26-2002, 4:51 AM
    • Manama
    • Posts 175

     

    plz help..

     

    also, how can i hide the entire rowButtons on click instead of hiding just one button?

Page 1 of 1 (7 items)