Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Placing hyperlink IP Address inside a TextBox ASP.Net

Posted on 2013-02-06
3
Medium Priority
?
952 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 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
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…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…

885 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