I have an aspx page where I need to check and display an error message on the page on page_load
. The error message is below:
<div class="errorMessage">The user ID or password you entered does not match our records. Please try again. <br />
You may also securely recover your <a href="#">User ID</a> or reset your <a href="#">Password</a> online.
</div>
this code block should be added to the page after chechking some conditions...and that part and some other functions are implemented in code behide function page_load()
how do i do this using only the behind the code in page_load()
function without writing it inline in the aspx file?
Create a div with an ID and a runat="server":
<div ID="divErrorMessage" runat="server" class="divErrorMessage"></div>
Then from your Page_Load event in the code behind, you can set the inner html of the div:
divErrorMessage.InnerHtml = "Your message";
Setting the flag, runat="server" makes the control available in the code behind
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With