Solved

Placing hyperlink IP Address inside a TextBox ASP.Net

Posted on 2013-02-06
3
891 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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