Asp.net Button组件在Twitter-Bootstrap主题下不起作用

我一直在使用twitter-bootstrap作为我的asp.net网站主题,在尝试制作一个简单的按钮执行一个事件时遇到了一些麻烦。 该按钮是一个asp组件,从我在论坛中看到的是,引导程序无法很好地管理asp.net组件,无论是脚本(最明显)还是CSS问题(我不知道,我不知道发生了什么事。

据我所知,按钮在我将其放入表单时会采取行动,但据我所知,这不是应该采取的行动。

并重定向到同一页面,但使用以下参数:

?ctl00%24MainContent%24LogUsernameText =&ctl00%24MainContent%24LogPasswordText =&ctl00%24MainContent%24loginBtn =登录+在21%

我已经尝试了许多我在其他人的问题中看到的答案,例如将其渲染为HTML按钮并使其成为runat="server" ,然后在页面加载时添加一个实例。

我怎么能通过这个?

母版代码:

        <!--         body { padding-top: 60px; padding-bottom: 40px; }      

bitRain Project

页面中的代码块:

 
Sign In

.cs文件代码:

 public partial class LoginN_Register : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void loginBtn_Click(object sender, EventArgs e) { Account log = new Account(); string username = LogUsernameText.Text; string password = LogPasswordText.Text; string authentication = log.UserLogin(username, password); if (!string.IsNullOrEmpty(authentication)) { // Create a new ticket used for authentication FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, // Ticket version username, // Username associated with ticket DateTime.Now, // Date issued DateTime.Now.AddMinutes(30), // Date to expire true, // "true" for a persistent user cookie authentication, //Role FormsAuthentication.FormsCookiePath); //Path authorized string hash = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie( FormsAuthentication.FormsCookieName, hash); if (ticket.IsPersistent) cookie.Expires = ticket.Expiration; Response.Cookies.Add(cookie); string returnUrl = Request.QueryString["ReturnUrl"]; if (returnUrl == null) returnUrl = "~/Users/User_Profile.aspx"; Response.Redirect(returnUrl); base.OnLoad(e); } else { Alert.Text = "
Warning! Best check yo self, you're not looking too good.
"; LogUsernameText.Text = "Fail"; } } }

我的猜测是有些脚本重定向我的按钮事件。 我找不到它。 我正在使用最新版本的bootstrap主题。

我找到了我的问题的答案,对于礼仪,你有选择UseSubmitBehaviour并将其设置为false,我的猜测是它会像普通的HTML提交按钮一样被检测到,并且bootstrap准备改变常规的HTML组件行为。 (我真的不知道如何用更好的词语。请随意编辑。)

我的意思是…… Bootstrap没有计划用asp.net组件100%工作,所以它将依赖于javascript命令。

它有逻辑,因为它是一个表单,它会抓取所有文本字段,当按钮被激活时,它会为你提交它们。 创建我上面提到的重定向,希望这可以帮助某人,因为我的大脑慢慢推迟并延迟了我2天的工作。

  

编辑和正确的解决方案:

实际上我开始探索更多它是如何工作的,这是一个validation问题,它只会在validation完成时提交,无论你是否拥有它们,所以如果你使用VS并且需要将Validation Required值改为Disabled ,不要担心按钮只会在其内部validation。

对于那些没有……礼仪吧,将这些添加到你的按钮html代码:

 ValidateRequestMode="Disabled" 

我决定用更可靠的信息改进这个答案,因为我注意到在搜索这个问题解决方案时我只能找到我的问题而不是任何其他来源的好答案,我几个月前找到了“正确的”解决方案…

如果它是你所针对的引导按钮的外观,那么asp按钮组件将不起作用。 使用

  

控制而不是。 它的工作方式与asp Button相同。