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?

try to use innerhtml instead of value.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.