Hi nauna,
Refer below sample.
HTML
<link type="text/css" rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css" />
<script src="https://code.jquery.com/jquery-1.12.4.js" type="text/javascript"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js" type="text/javascript"></script>
<script type="text/javascript">
function UpdateTime(time) {
$("#dialog").dialog({
create: function () {
$(this).closest('div.ui-dialog')
.find('.ui-dialog-titlebar-close')
.click(function (e) {
window.location.href = 'CS.aspx';
});
}
});
document.getElementById("<%=Label1.ClientID %>").innerHTML = time;
}
</script>
<div id="dialog" title="Basic dialog">
<p id="demo">
</p>
</div>
<asp:Button ID="Button1" runat="server" Text="Open" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server"></asp:Label>
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
string time = DateTime.Now.ToString();
ClientScript.RegisterStartupScript(this.GetType(), "UpdateTime", "window.onload = function() { UpdateTime('" + time + "');};", true);
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Label1.Text = DateTime.Now.ToString()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim time As String = DateTime.Now.ToString()
ClientScript.RegisterStartupScript(Me.[GetType](), "UpdateTime", "window.onload = function() { UpdateTime('" & time & "');};", True)
End Sub
Screenshot