This is the JavaScript function that I'm calling:
<script type="text/javascript" language="javascript">
function divConfirm(data) {
document.getElementById('data').innerHTML=data;
document.getElementById('divConfirmPrompt').style.visibility = "visible";
}
</script>
The below Div tag I'm using to display the Messagebox in the Webform:
<div id="divConfirmPrompt" style= "position:absolute;z-index:1000; width:350px;height:150px;border: solid black 1px; padding: 10px;background-color:rgb(212,208,200);visibility:hidden;top:38%;left:41%;vertical-align:middle" align="center" >
<span id="data"> </span>
<asp:button runat="server" id="btnClsYes" text="OK" CssClass="button" style="margin-left :15px;margin-top:25px" onclick="btnClsYes_Click" />
</div>
I'm calling the above JavaScript function from CodeBehind:
ScriptManager.RegisterStartupScript(this, typeof(Page), "OnClientClicking", "divConfirm('" + "Error message" + "');", true);
As of now I'm implementing the same JavaScript function and div tag in all the pages to display the Message box in ASP.NET Webform...rather I want to write the same JavaScript function and the div tag in one .js file and I want to take the reference of that page and to all other pages...is it possible? and may I know how to implement the div tag in .js file?
What I have tried:
I'm trying to display the below Div tag in .js:
<div id="divConfirmPrompt" style= "position:absolute;z-index:1000; width:350px;height:150px;border: solid black 1px; padding: 10px;background-color:rgb(212,208,200);visibility:hidden;top:38%;left:41%;vertical-align:middle" align="center" >
<span id="data"> </span>
<asp:button runat="server" id="btnClsYes" text="OK" CssClass="button" style="margin-left :15px;margin-top:25px" onclick="btnClsYes_Click" />
</div>