Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
In my asp.net c# website button click event is not firing. I don't get the actual problem. my controls are in .ascx page

What I have tried:

this is my .ascx code
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <title></title>
<link rel="icon" href="favicon.ico"/>
        <link rel="stylesheet" href="css/bootstrap2.css"/>
        <link rel="stylesheet" href="css/bootstrap2.min.css"/>
        <link rel="stylesheet" href="css/font-awesome2.css"/>
        <link rel="stylesheet" href="css/font-awesome2.min.css"/>
        <link rel="stylesheet" href="style4.css"/>
        <link href='https://fonts.googleapis.com/css?family=Raleway:500' rel='stylesheet' type='text/css'/>


            <script type='text/javascript'>
                 $('#cleftw').css('display', 'none');
        var maxLimit4 = 80;
       function kio() {
            $('#<%= Status.ClientID %>').keyup(function () {
                var lengthCount = this.value.length;              
                if (lengthCount > maxLimit4)
                {
                    this.value = this.value.substring(0, maxLimit4);
                    var charactersLeft = maxLimit4 - lengthCount + 1;                   
                }
                else
                {
                    var charactersLeft = maxLimit4 - lengthCount;                   
                }
                $('#cleftw').css('display', 'block');
                $('#cleftw').text(charactersLeft + ' Characters left');
            });
        };
    </script>
            <style type="text/css">
                .auto-style1 {
                    width: 0px;
                    height: 35px;
                }
            </style>
            </head>

  

            <body>
              
    <header id="profile-bg">
        <div class="row"  runat="server">
            <div class="container"  runat="server">
                    <div class="col-md-12"  runat="server">
                        <div class="col-md-9"  runat="server">
                            <img src="images/logo-transparent.gif" alt="logo" class="img-responsive text-left" width="200px">
                            <img alt="logo" class="auto-style1" src="../img/logo.png" / visible="false">
                        
                        <div class="col-md-3"  runat="server">
                            <a href="index.html"><img src="images/home-btn.png" alt="logo" class="img-responsive text-right" width="150px"></a><br />
                            
                             
                    
                        
                    <div class="col-md-12"  runat="server">
                        <div class="col-md-3 text-center"  runat="server">
                            <asp:Label  ID="LoginName" runat="server" />
                            <br />
                            <%--<img src="images/profile-photo.jpg" alt="logo" class="img-responsive center-block" width="150px">                        --%>
                            <asp:Image ID="Image5" runat="server" class="img-responsive center-block" width="150px" />
                                  <%-- <button type="submit" class="btn btn-default">Change</button>          --%>
                            <asp:Button ID="change" runat="server" Text="Change"  class="btn btn-default" OnClick="Button1_Click1" />
                             
                        
                        <div class="col-md-6"  runat="server">
                            <form class="form-inline" role="form" id="name_search" >
                                    <div class="form-group">
                                        <label for="name">By Name:</label>
                                        <%--<input type="name" class="form-control" id="name">--%>
                                        <asp:TextBox ID="txtSearch" runat="server" class="form-control" >
                                    </div>
                                        <%--<button type="submit" class="btn btn-default">Search</button>--%>
                                 <asp:Button ID="btnSearch" runat="server" Text="Search" class="btn btn-default"  OnClick="btnSearch_Click" EnableViewState="false" CausesValidation="false" />
                            </form>
                            <form class="form-inline" role="form" >
                                    <div class="form-group"  runat="server">
                                        <label for="status">Status:     </label>
                                       <%-- <input type="status" class="form-control" id="status">--%>
                                         <asp:TextBox ID="Status" runat="server" AutoPostBack="True" BackColor="White" class="form-control" BorderColor="Black"  BorderStyle="Dotted" MaxLength="55" meta:resourceKey="TextBox2Resource1" TextMode="MultiLine"  Enabled="False">
                                    
                                        <%--<button type="submit" class="btn btn-default">Change</button>--%>
                                
                                <asp:Button ID="btnstatuschange" runat="server" class="btn btn-default" Text="Change" OnClick="btnstatuschange_Click"  CausesValidation="false"/>



                                 <div class="form-group">
                                         <asp:TextBox ID="changestatus" runat="server"  TextMode="MultiLine"  Visible="false">
            <asp:Button ID="btnDone" runat="server"   CausesValidation="false"  OnClick="btnDone_Click" Text="Send" Visible="false"/> <%-- meta:resourceKey="btnDoneResource1"--%>
                                     </div>

                            </form>
                            <form class="form-inline" role="form" >
                                       <%-- <button type="submit" class="btn btn-default">Home</button>--%>
                                <asp:Button ID="Home" runat="server" class="btn btn-default" OnClick="Home_Click" Text="Home" />
                                      <%--  <button type="submit" class="btn btn-default">View Information</button>--%>
                                <asp:Button ID="view_info" runat="server" class="btn btn-default"  OnClick="view_info_Click" Text="View Information"/>
                            </form>
                     
                        
                        <div class="col-md-3"  runat="server">
                            <div class="logout"  runat="server">
                                           <%--<a href="#">Logout</a> | <a href="#">My Profile</a>--%>
                                <asp:LinkButton ID="Login" runat="server" CausesValidation="false"  OnClick="Login_Click" Text="Login |">
                                <asp:LinkButton ID="Logout" runat="server" CausesValidation="false"  OnClick="Logout_Click" Text="Logout |">
             <asp:LinkButton ID="MyProfile" runat="server" CausesValidation="false"  OnClick="MyProfile_Click" Text="My Profile">
                            
                        
                
            
        
    </header>

<asp:ScriptManager ID="ScriptManager1" runat="server" />
           
</body>
</html>
Posted
Updated 25-May-16 21:06pm
v2
Comments
Kishor-KW 26-May-16 2:36am    
there is no answer to a question or my question is wrong?
Karthik_Mahalingam 26-May-16 6:05am    
whenever you are posting a question, you should provide more info related to your problem and post only the relevant code to the issue, No one will read the whole code.
so make it simple and easy for the users to read, then they will show interest on this post, else mostly it will be ignored.
its good that you have found the solution and posted the same.

Thanks
karthik

1 solution

HTML
<form class="form-inline" role="form" id="name_search" >

actual problem is form HTML form tag. I removed it and event is working. form tag required runat="server" to fire event of control with in it. but we can't specify runat to multiple forms tag(Don't know why). one page allow only one runat tag. at last it is working.
 
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