Link to home
Start Free TrialLog in
Avatar of amillyard
amillyardFlag for United Kingdom of Great Britain and Northern Ireland

asked on

dynamic hyperlink using text entry box and button

Development envoirnment: asp.net 2.x, Visual Studio Pro using Web Developer.  IIS6 / Wins 2003 server.

Hi there,

I am trying to create a dynamic hyperlink -- i.e. you can type the hyperlink via the textbox entry field, then click the button to activate the link.

I have got as far as below -- but not quite there yet...

asp:TextBox ID="TextBox_EnterHyperlink" runat="server" Font-Names="Verdana" Font-Size="Small"></asp:TextBox>
            <input type="button" value="Jump to Link" onClick="self.location.href='TextBox_EnterNumber.Text';
" style="font-family: Verdana"><br />

Thank you in advance for your time and efforts with this enquiry.
Avatar of Rejojohny
Rejojohny
Flag of United States of America image

change the input click event to ..

 <input type="button" value="Jump to Link" onClick="self.location.href=document.location.href=document.getElementById('TextBox_EnterHyperlink').value;" style="font-family: Verdana">
ASKER CERTIFIED SOLUTION
Avatar of Rejojohny
Rejojohny
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of BurntSky
BurntSky

You could do this a couple different ways... it appears you want to do it in JavaScript.  If so, I suppose I'd do something like this:

<asp:TextBox runat="server" ID="TextBox1" />
<input type="button" value="Jump to Link" onclick="window.location=<%=this.TextBox1.ClientID%>.value" />

You could also do it on the server side:

<asp:TextBox runat="server" ID="TextBox1" />
<asp:Button runat="server" ID="Button1" Text="Jump to Link" OnClick="Button1_Click" />

then in your codebehind put this:

protected void Button1_Click(object sender, EventArgs e)
{
    this.Response.Redirect(this.TextBox1.Text);
}
Avatar of amillyard

ASKER

spot on !

thank you :-)