Puzzled about a ASP.NET background using JS pop-up message... For the explanatio


Reception:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="alerttest.aspx.cs" Inherits="admin_alerttest" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

</div>
input id="hideInput" runat="server" type="hidden" />
</form>
</body>
<script type="text/javascript">
if (document.all("hideInput").value != "") {
alert(document.all("hideInput").value);
document.all("hideInput").value = "";
}
</script>
</html>

Backstage:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admin_alerttest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void test_Click(object sender, EventArgs e)
{
hideInput.Value = "ssss";
}
}


Is the a button to change the hidden inside the INPUT value, and then JS INPUT non empty words on the value of alert, but there is a problem, is a pop-up message, look at the Webpage source code INPUT value has not been emptied, the last sentence is the document.all ("hideInput").Value = "" don't play? Thanks a million. You guys!!!

Started by Cathy at February 04, 2016 - 9:33 PM

Has been tested, no problem. .


<script type="text/javascript">
if (document.all("hideInput").value != "") {
alert(document.all("hideInput").value);
document.all("hideInput").value = "";
alert(document.all("hideInput").value); //This alert is empty.. No problem.
}
</script>

Posted by Enoch at February 12, 2016 - 10:19 PM

But the pop up window, or back to the page will refresh again the pop-up message box, there is a view of the source file, found that the INPUT value value did not empty, don't know why!!

Posted by Cathy at February 25, 2016 - 10:44 PM

Refresh your use is window.location.reload (do);?

Above you all on the form form, refresh when executing server control posts back, equivalent to automatically perform once you just method. .

To avoid the refresh appear this kind of circumstance, you must use the window.location.href = "xxx.aspx"

Posted by Enoch at December 09, 2016 - 4:24 PM

, Look at the Webpage source code INPUT value and is not empty,

Not because you see the source code.

Posted by Edison at December 23, 2016 - 4:48 PM

No server controls what problems are gone, value front-end JS empty input directly can do, without waste of network and server resources

Posted by Carina at December 30, 2016 - 5:45 PM

Server control is convenient to modify the background pop-up information.

Posted by Cathy at January 04, 2017 - 6:41 PM

If my page and other links, these links to other pages, once back to this page will pop up dialog box

Posted by Cathy at January 05, 2017 - 7:18 PM

In the<head>Add a <META NAME= "save" CONTENT= "history" > save, back to try again

Posted by Enoch at January 09, 2017 - 8:43 PM

This has what effect? I added, I added a link on the page, point after the retreat would have!

Posted by Cathy at January 13, 2017 - 8:12 PM