Solved

Placing hyperlink IP Address inside a TextBox ASP.Net

Posted on 2013-02-06
3
864 Views
Last Modified: 2013-03-02
I have a requirement ASP.Net text box will have a hyperlink with IP Address and when the user clicks it should open up the IP address.

I have issues placing a hyperlink inside a text box.

Please help.
0
Comment
Question by:Prak290679
  • 2
3 Comments
 
LVL 20

Expert Comment

by:informaniac
ID: 38861029
Textbox can't contain links.

Why a textbox?
0
 
LVL 26

Expert Comment

by:Alan Warren
ID: 38861696
Is your textbox databound?
Is your textbox enabled or disabled?
Can the end-user enter text in the textbox?

The reason I ask, is because the asp .net textbox control does not have an OnClick event, nor does it have by default an OnClientClick event.

You could use the  OnTextChanged event, which will fire when the user hits [Enter] or leaves the control.
    Protected Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
        Response.Redirect("http://" & sender.text, True)
    End Sub

Open in new window

Alan
0
 
LVL 26

Accepted Solution

by:
Alan Warren earned 500 total points
ID: 38861807
It works a bit better if you use an iframe to display the resolved URL site on your asp .net page.
<%@ Page Language="VB" title="MyNav"%>

<!DOCTYPE html>

<script runat="server">

    Protected Sub TextBox1_TextChanged(sender As Object, e As EventArgs)
        MyNav.Attributes.Item("src") = "http://" & sender.text
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    Enter an IP: <asp:TextBox ID="TextBox1" runat="server" OnTextChanged="TextBox1_TextChanged" ></asp:TextBox><br />
    <iframe style="z-index: -1 !important;" id="MyNav" frameborder="0" 
                            height="400" scrolling="no" src="#" width="600" runat="server"></iframe>
    
    </div>
    </form>
</body>
</html>

Open in new window

Alan
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Syntax Issue with SSIS module 26 105
ASP Repeater control - onl;y show if flag is true 7 16
ASP.NET MVC - Views 3 22
Upgrade code from VS 2010 to VS 2015 7 21
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question