Suppose i have one label & one button. Suppose labe text is
http://www.dreamincode.net/forums/showforum30.htm
I Want that on button click,my form is redirtected to the above URL using JS.
FIRST METHOD
protected void Page_Load(object sender, EventArgs e)
{
Button2.Attributes.Add("onclick", "navigated()");
}
<script language ="javascript" type ="text/javascript" >
function navigated()
{
var url=document.getElementById("Label1").value;
alert(url);
}
</script>
SECOND METHOD
protected void Page_Load(object sender, EventArgs e)
{
Button2.Attributes.Add("onclick", "navigated()");
}
<script language ="javascript" type ="text/javascript" >
function navigated()
{
var url=document.getElementById('<%= Label1.ClientID %>').value;
alert(url);
}
</script>
In both the cases,in url undefined is coming. y SO?