0
我有一個母版頁,其中包含兩個圖像按鈕,一個用於帳戶登錄,另一個用於搜索網站。附加的aspx頁面包含一個提交按鈕的一些freebees的請求表單。所有按鈕都具有運行不同腳本的點擊事件,然後將它們重定向到它們各自的頁面。主按鈕不會相互衝突。搜索執行搜索並且登錄執行登錄。但是,當包含請求表單的頁面加載到主頁面時,它會將其URLredirect強加在主頁面按鈕上,導致從兩個按鈕回發請求表單。我知道這是.NET的一個已知問題,整個頁面是一個Web窗體。我將UseSubmitBehavior設置爲False,希望點擊事件優先,但沒有改變。任何人都有一個想法如何停止提交按鈕覆蓋圖像按鈕?非常感謝提交按鈕覆蓋的所有按鈕點擊事件
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
謝謝。不,不使用jQuery – 2014-10-07 20:39:55