Solved

Placing hyperlink IP Address inside a TextBox ASP.Net

Posted on 2013-02-06
3
843 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now