没有/default.aspx的主页上不触发按钮事件处理程序 [英] Button Event Handler Not Firing on Homepage Without /default.aspx

查看:65
本文介绍了没有/default.aspx的主页上不触发按钮事件处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里不知所措.在我的应用程序(default.aspx)的根目录上,我在页面上具有一个基本的ASP.NET Button控件,该控件具有通过其onClick事件连接的事件处理程序.

I'm at a loss over here. On the root of my application (default.aspx), I have a basic ASP.NET Button control on the page with an event handler wired up via its onClick event.

因为它是根目录,所以单击/或default.aspx将带您进入此页面.单击按钮时,仅当FilePath在url(default.aspx)中时,事件处理程序才会被调用.

Since it's the root, hitting either / or default.aspx will bring you to this page. When clicking the button, the event handler is only getting called if the FilePath is in the url (default.aspx).

更清楚的是:

whatever.com/default.aspx< ------单击按钮时将调用事件处理程序

whatever.com/default.aspx <------ The event handler gets called when the button is clicked

whatever.com< --------单击按钮时未调用事件处理程序.

whatever.com <------ event handler is not getting called when button is clicked.

我应该注意,此页面上没有太多内容.不包括jquery文件,没有javascript,除了DropDownList和此Button之外,什么也没有.Web.Config也没有太多内容,至少我看不到会对它有任何影响.

I should note, this page doesn't have much on it. No jquery files included, no javascript, nothing besides a DropDownList and this Button. The Web.Config doesn't have much in it either, at least nothing I can see that would have any impact on this.

<asp:Button ID="btnSelection" OnClick="btnSelection_OnClick" runat="server" Text="Submit" />

protected void btnSelection_OnClick(object sender, EventArgs e)
{
    throw new Exception("Test"); // Only reaches here if /default.aspx is in the url
}

这可能是我所缺少的小东西.任何指导将不胜感激.

This is probably something small I'm missing. Any guidance would be greatly appreciated.

推荐答案

查看此链接:如果什么也没有,它应该为您指明正确的方向.

If nothing, it should point you in the right direction.

这篇关于没有/default.aspx的主页上不触发按钮事件处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆