我有一个母版页,其中包含两个图像按钮,一个用于帐户登录,另一个用于搜索网站。附加的aspx页面包含一些带有提交按钮的freebees的请求表单。所有按钮都有单击事件,运行不同的脚本,然后将它们重定向到各自的页面。主按钮不会相互冲突。搜索执行搜索并登录执行登录。但是,当包含请求表单的页面在主页面中加载时,它会在主页面按钮上强加其URLredirect,从而导致从两个按钮回发请求表单。我知道这是.NET的一个已知问题,整个页面都是一个webform。我在所有这些上设置了UseSubmitBehavior为False,希望click事件优先,但没有变化。任何人都知道如何停止提交按钮覆盖图像按钮?非常感谢
aspx:Request Form Button
<asp:Button ID="btSubmit" CssClass="FormBtn" runat="server" Text="Submit" OnClick="btSubmit_Click"
OnClientClick="window.scrollTo = function(x,y) { return true; };"
value="greaselid" UseSubmitBehavior="False"/>
CS:Request Form button event
protected void btSubmit_Click(object sender, EventArgs e)
{
var validator = new Recaptcha.RecaptchaValidator
{
PrivateKey = ConfigurationManager.AppSettings["RecaptchaPrivateKey"],
RemoteIP = Request.UserHostAddress,
Challenge = Context.Request.Form[RECAPTCHA_CHALLENGE_FIELD],
Response = Context.Request.Form[RECAPTCHA_RESPONSE_FIELD]
};
//after validation email request is sent and then return to same page
aspx:Login
<div id="logonbox_SB">
<div id="FS_1">
<asp:Label ID="Label1" class="LoginLabel1" runat="server" Text="Account Number"></asp:Label>
<asp:TextBox ID="AcctNum" class="AcctNumTexbox" runat="server"></asp:TextBox>
</div>
<div id="FS_2">
<asp:Label ID="Label2" runat="server" class="LoginLabel2" Text="Access Code"></asp:Label>
<asp:TextBox ID="MtrNum" class="MtrNumTexbox" runat="server"></asp:TextBox>
</div>
<asp:ImageButton ID="Login1" type="submit" runat="server" class="boxsubmitbtn" src="/resources/buttons/login.gif"
OnClick="LogInBtn_Click" UseSubmitBehavior="False"/>
</div>
CS:Login
protected void LogInBtn_Click(object sender, EventArgs e)
{
string AcctNbr = AcctNum.Text;
Session["AcctNum"] = int.Parse(AcctNbr);
string MtrNbr = MtrNum.Text;
Session["MtrNum"] = MtrNbr;
//account is verified and redirected to user's account page
aspx:search
<div id="SearchForm">
<asp:TextBox ID="searchQuery" runat="server" size="15" />
<asp:ImageButton ID="searchButton" runat="server" Text="GO" src="/RESOURCES/buttons/go_button.gif" value="submit2" style="font-size: 11px;" class="GoButton" alt="Go" OnClick="searchButton_Click" UseSubmitBehavior="False"/>
</div>
cs:search
protected void searchButton_Click(object sender, EventArgs e)
{
StringBuilder redirectUrl = new StringBuilder();
//The URL to your resultpage
redirectUrl.Append("~/about/search_results.aspx");
//Add your CSE unique identifier
redirectUrl.Append("?cx='google_account_nbr'%3Aiylaun_ayf0");
//Add your advertising location code
//redirectUrl.Append("&cof=FORID%3A11");
//The search query
redirectUrl.Append("&q=" + searchQuery.Text);
//Redirect to the resultpage
Response.Redirect(redirectUrl.ToString());
}
//user is redirected to search result page
答案 0 :(得分:0)
您可以使用AJAX。只需创建一个按钮,即可将第一个div中的数据发送到..,您希望在哪里发送信息。然后,在同一个函数中,使用您想要的信息调用另一个AJAX。你在使用jquery吗? :)