Solved

Placing hyperlink IP Address inside a TextBox ASP.Net

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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 demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

20 Experts available now in Live!

Get 1:1 Help Now