I am new to Javascript and kinda struck at one point. So here is what I want to achieve:
I have a user control (having a textbox and label)
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="JMTextBox.ascx.cs" Inherits="Controls_JMTextBox" %>
<asp:Panel ID="pnlMain" runat="server" BackColor="White">
<table style="cellPadding:0px; width:100%;">
<tr>
<td>
<asp:TextBox runat="server" ID="txtEntry" CssClass="form-text required" />
</td>
<td>
<div class="box" id="dvAlert">
<div class="center">
<div class="dialog-1">
<asp:Label runat="server" ID="lblAlertText" style="padding:5px;" Width="200" ></asp:Label>
<div class="left-point"></div>
</div>
</div>
</div>
</td>
</tr>
</table>
</asp:Panel>
JMTextBox.js:
function SetLabelText(textStr) {
<<change label text here>>
}
In the code behind, I have 2 string properties: AlertText and InfoText
public string InfoText
{
get { return _infoText; }
set { _infoText = value; }
}
public string AlertText
{
get { return _alertText; }
set { _alertText = value; }
}
On aspx, I am using this control in aspx page in an entry form
<JM:JMTextBox ID="txtUserName1" runat="server" class="required" InfoText="This is Info" AlertText="This is alert" />
By default, label displays info text, but in JS function of aspx page, where fields are validated, I want to change info text to alert text.
Thanks in advance
What I have tried:
I have tried to google it out but mostly getting answers to invoke JS function from code behind using
Page.ClientScript.RegisterStartupScript
which isn't my requirement. I want to change it through JS only when fields are validated.