function onPostBack()
{
var y=generateRandomSequence();
var hdnGuid=document.getElementById("hdnGuid");
hdnGuid.value=y;
}
function generateRandomSequence()
{
var g = "";
for(var i = 0; i <
32; i++)
g +=
Math.floor(Math.random() * 0xF).toString(0xF)
return g;
}
The above javascript function is referred in a JS files and called on the button submit click as shown in the below HTML code snippet.
<title>Untitled Page</title>
<script type="text/javascript"
language="javascript"
src="Client-Side_Validn.js"
temp_src="Client-Side_Validn.js"></script>
</script>
</head>
<body>
<form id="form1"
runat="server"
onsubmit="onPostBack()">
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>
HttpModule code
The next important code is the 'HttpModule' code. As a first step let's create a simple GUID class which help us store the GUID values as shown in the below figure.
public class GuidClass
{
public GuidClass()
{
//
// TODO: Add constructor logic here
//
}
private string guid;
public string Guid
{
get
{
return guid;
}
set
{
guid = value;
}
}
}
The next step is to create a simple 'HttpModule' class which overrides the 'page_Init' event and the 'page_Load' event.