Hyperlink in a TextBox - Possible?

Discussion in 'ASP .Net' started by theintrepidfox@hotmail.com, Mar 3, 2005.

  1. Guest

    Dear Group

    Simple question or maybe not.
    I have a text box that contains a hyperlink e.g. http://www.mysite.com.
    Is it possible to get that hyperlink to work so when a user clicks on
    it it brings up this website?

    I know about link labels etc but in this case this is a contact form
    which is used to view and update information so if it would be a link
    label the user wouldn't be able to enter the hyperlink in the first
    place. Just thought whether there's a possible way instead of creating
    two controls, a textbox that is displayed for data entry and a link
    label for viewing the data.

    Thanks very much for your help & efforts!

    Best Regards,

    Martin
    , Mar 3, 2005
    #1
    1. Advertising

  2. No, this won't work in a regular textbox.
    You could fake it with Javascript like these free rich textbox controls do:
    http://www.exporttechnologies.com/softwareDownloads.asp
    http://www.interactivetools.com/products/htmlarea/
    http://www.freetextbox.com/

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net



    <> wrote in message
    news:...
    > Dear Group
    >
    > Simple question or maybe not.
    > I have a text box that contains a hyperlink e.g. http://www.mysite.com.
    > Is it possible to get that hyperlink to work so when a user clicks on
    > it it brings up this website?
    >
    > I know about link labels etc but in this case this is a contact form
    > which is used to view and update information so if it would be a link
    > label the user wouldn't be able to enter the hyperlink in the first
    > place. Just thought whether there's a possible way instead of creating
    > two controls, a textbox that is displayed for data entry and a link
    > label for viewing the data.
    >
    > Thanks very much for your help & efforts!
    >
    > Best Regards,
    >
    > Martin
    >
    Steve C. Orr [MVP, MCSD], Mar 3, 2005
    #2
    1. Advertising

  3. Guest

    Thanks Steve!
    , Mar 4, 2005
    #3
  4. kanjo01

    Joined:
    Mar 15, 2011
    Messages:
    1
    I realize this is a very old thread, but I have a VERY easy to implement solution for this requirement.

    Imagine for a moment that you have a text area on a form that someone can enter a URL into... handling the text entry is of course handled for you by the input type="text", but wouldn't it be nice if someone could click on the url in that text box and have the browser take them there.

    The following approach will address that requirement and it has been tested on IE, Safari, Chrome and Firefox and worked on all of them.

    Add the following script to the top of your page.

    <!-- -->
    <!-- Following script used to open a child window -->
    <!-- -->
    <script language="javascript">
    function Reload() {
    window.location.reload();
    }
    function NewWindow(mypage, myname, w, h, scroll, statusbar, tool, menu, location) {
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+', status='+statusbar+',toolbar='+tool+', menubar='+menu+', location='+location+',resizable=no';
    win = window.open(mypage, myname, winprops);
    if (parseInt(navigator.appVersion) >= 4) {
    win.window.focus();
    }
    }
    </script>
    <script language="javascript">
    function Close()
    {
    self.close();
    if (opener && !opener.closed)
    {
    opener.Reload();
    }
    }
    </script>


    Next, modify your input type=text to include invocation of the script.

    For example, this is what the input tag looks like without the hyperlink support.

    <input type="text" name="orgurl" size="30" tabindex="2" value="http://url">
    ... and as you would expect, the text is displayed in this text box as "http://url" but there is no hyperlink capability.

    Now modify the input tag to invoke the script as follows (adding the onClick):

    <input type="text" name="orgurl" size="30" tabindex="2" value="http://url" onClick="javascript:NewWindow('http://url,'name','1100','900','yes','yes','yes','yes', 'yes')">

    The text will show as before, and if you click on that textbox, a window opens with the target page in it. To be clear, the cursor doesn't change when you do a mouseover of the text box, but if you click on the text box... off it goes.

    (change the parameters you send to the script as needed of course)
    kanjo01, Mar 15, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?d3J5dGF0?=

    Parsing Textbox Value Through Hyperlink

    =?Utf-8?B?d3J5dGF0?=, Sep 19, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    4,076
    =?Utf-8?B?U2l2YSBN?=
    Sep 19, 2005
  2. davetichenor
    Replies:
    1
    Views:
    806
    Eliyahu Goldin
    Oct 30, 2006
  3. Luc
    Replies:
    3
    Views:
    551
    Alexey Smirnov
    Nov 20, 2009
  4. Ken
    Replies:
    1
    Views:
    362
    Alvin Bruney
    Aug 16, 2003
  5. Dave
    Replies:
    0
    Views:
    925
Loading...

Share This Page