PDA

View Full Version : [CLOSED]Setting text property of label



Jurke
Oct 15, 2008, 10:47 AM
Hi
I have a label that Im trying to set the text property of, but the javascript will not even find the control. The label is on a parent page and the javascript . Anyone has an idea how to make this work?



<script type="javascript">
test()
{
parent.&#100;ocument.form1.lblInfo.value = "Value;
}
</script>

<ext:Label ID="lblInfo" runat="server" AutoWidth="true" />



Best regards
Mikael Jürke

Vladimir
Oct 15, 2008, 11:13 AM
Hi,

Can you post full code of example? May be your label in NamingContainer (master page or something else). In this case the ID and ClientID will be different. We use ClientID as ID for javascript controls

Jurke
Oct 15, 2008, 11:26 AM
Hi
Here is a simple example, but without the parent page. This is not working for me aswel.






<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test_Default" %>


<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">


<head id="Head1" runat="server">


<title></title>


<link href="TravelPerfectSalesPort.css" rel="stylesheet" type="text/css" />


<script type="text/javascript">





function SetValue()


{


&#100;ocument.form1.lblInfo.value = "Value";


}





</script>








</head>


<body onload="SetValue();">


<form id="form1" runat="server">


<ext:ScriptManager ID="ScriptManager1" runat="server">


</ext:ScriptManager>





<ext:Label ID="lblInfo" runat="server">


</ext:Label>


</form>


</body>


</html>

Best regards
Mikael Jürke

Vladimir
Oct 15, 2008, 12:08 PM
Hi Mikael,

1. Don't used any Coolite js objects on Body Load event because at this moment the Coolite init script has not started yet. You can use ScriptManager DocumentReady event for it.

2. All Coolite controls accessable through window object
3. The new value for label must be set with setText function



function SetValue()
{
window.lblInfo.setText("Value");
}

Jurke
Oct 15, 2008, 1:19 PM
Okay, thanks! works great!

Best regards
Mikael Jürke