简体   繁体   中英

The click event of button isn't trigged in asp.net

I have button in my page as you can see here :

  <div class="buttonPossion">
                    <asp:Button ID="btnFinal" runat="server" Text="دانلود مقاله" CssClass="buttonBlue" OnClick="btnFinal_Click"/>
                </div>

The click event of this button is :

protected void btnFinal_Click(object sender, EventArgs e)
    {
        int count =
            dbcontext.tblJurorArticles.Where(i => i.articleid == articleId && i.jurorUsername == Session["juror"])
                     .Count();
        if (count == 1)
        {
            Response.Redirect("../AdminPortal/DownloadArticleHandler.ashx?File=" +
                              obj.Return_filelocation_article(articleId.ToString()));
        }
        else
        {
            Response.Redirect("asda");
        }
    }

But when i click on the button it doesn't work .the important things is all my buttons in the page are disabled .

If the html code is needed ,i can include it in my question.

The webconfig

 <?xml version="1.0"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="DB-Conference-CivilConstruction" connectionString="Data Source=176.9.90.204,9992;Initial Catalog=DB-Conference-CivilConstruction;User ID=DB-Conference-CivilConstruction-user; password=123qweQWE@;"
      providerName="System.Data.SqlClient" />
    <!--<add name="DB-Conference-CivilConstruction" connectionString="Data Source=192.168.223.75;Initial Catalog=DB-Conference-CivilConstruction;User ID=DB-Conference-CivilConstruction-user; password=123qweQWE@;"
      providerName="System.Data.SqlClient" />-->

  </connectionStrings>
   <system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>

  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
   <httpRuntime maxRequestLength="1048576" />
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
</configuration>

Best regards

If your eventClick invoke a postback and Fire the page_Load function without moving to your click event hundler, and you are sure that OnClick attribute has the right event hundler name the you have to check your web.config

in this section

<appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="xxx" />
  </appSettings>

change it to

<appSettings>
    <add key="aspnet:MaxHttpCollectionKeys" value="5000" />
  </appSettings>

And if the "MaxHttpCollectionKeys" does not exist add it.

and change this config under the

<configuration> 
<system.web>
<httpRuntime maxRequestLength="xxx" />

to

<configuration> 
    <system.web>
    <httpRuntime maxRequestLength="51200" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM