Click here to Skip to main content
15,936,119 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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%;">
						<asp:TextBox runat="server" ID="txtEntry" CssClass="form-text required" />
						<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>


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
which isn't my requirement. I want to change it through JS only when fields are validated.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900