1
我已經從服務器side.It正常工作稱爲javascript代碼,但現在一旦用戶使用瀏覽器的後退按鈕,並涉及到我的網頁,Javascript代碼(ieScriptManager.RegisterStartupScript)被稱爲再次。 我怎樣才能防止發生。我相信在頁面加載的東西。 有人可以檢查和幫助。防止在asp.net上瀏覽器的JavaScript後退按鈕
以下是我的代碼。
protected void Button1_Click1(object sender, EventArgs e)
{
this.ADDMsg.Visible = false;
string dropdownvalue = HiddenField.Value;
this.ADDMsg.Text = "";
bool flag = true;
try
{
if (flag)
{
if (this.vpsReq == null)
{
this.vpsReq = new VPSRequest();
try
{
this.Record_Request_VPS(this.vpsReq, dropdownvalue);
ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowStatus", "javascript:alert('Request Submitted');", true);
}
catch (Exception exception2)
{
this.ADDMsg.Text = exception2.Message;
}
}
else
{
}
}
else
{
this.ADDMsg.Text = "Please correct the errors above and click <i>Submit</i>.";
}
}
catch (NullReferenceException)
{
}
}
和頁面加載是:
protected void Page_Load(object sender, EventArgs e)
{
txtFrom.Attributes.Add("readonly", "readonly");
if (IsPostBack)
{
ClientScript.RegisterHiddenField("isPostBack", "1");
}
clnImplDate = txtFrom.Text;
User = new User();
try
{
User = (User)this.Session["User"];
}
catch (Exception)
{
}
if ((User.UserID == null) || (User.UserID == ""))
{
User = Utility.GetUserInfo(User);
}
this.Session["User"] = User;
}
另外,可變的IsPostBack的使用如下所示(思想噸o增加爲了更清楚,該代碼)。
$(document).ready(function() {
var isPostBackObject = document.getElementById('isPostBack');
if (isPostBackObject == null) {
$('#<%= ADDMsg.ClientID %>').hide();
}
$("#" + "ClaimVEBP").hide();
});
任何解決方案?即使使用jQuery,也是值得讚賞的。
感謝您的回覆,但仍相同problem.once我回來了使用瀏覽器的後退按鈕,我得到了彈出說:「要求提交的'」 – vish1990