I'm new to asp.net. (refugee from old asp)
I have a database field "Website", which is a url and I want it be a
hyperlink. I can display the url as text using:
<asp:literal id="litWebsite" runat="server"></asp:literal>
But I want it to be a hyperlink. I tried enclosing the above line in
an <a href......> tag but no good.
Any tips for a newbie??
Thanks
Leslie 7 13091
Well it could be as simple as this:
<asp:literal id="litWebsite" runat="server"><a href='whatever.aspx'>click
here</a></asp:literal>
Or you could put a hyperlink web server control in there, etc.
--
I hope this helps,
Steve C. Orr, MCSD http://Steve.Orr.net
<les> wrote in message news:7c********************************@4ax.com... Thanks Steve, but how would you do this?
<asp:literal id="litWebsite" runat="server">???????????</asp:literal>
On Sat, 5 Jul 2003 15:58:00 -0700, "Steve C. Orr, MCSD" <St***@Orr.net> wrote:
Try doing it the other way around: enclosing your hyperlink in between
theliteral tags.
-- I hope this helps, Steve C. Orr, MCSD http://Steve.Orr.net
<les> wrote in message news:s0********************************@4ax.com... I'm new to asp.net. (refugee from old asp) I have a database field "Website", which is a url and I want it be a hyperlink. I can display the url as text using:
<asp:literal id="litWebsite" runat="server"></asp:literal>
But I want it to be a hyperlink. I tried enclosing the above line in an <a href......> tag but no good.
Any tips for a newbie?? Thanks Leslie
uh, no that's not how to do it! :-)
<asp:LinkButton id="link1" runat=server />
then, in your code-behind:
at top:
Protected link1 as LinkButton
and finally, within your code - one way to do this:
link1.text=o_dataRow.item("WebSite")
That's it...
PS: this is pretty basic stuff, not complicated. Glad to answer this kind
of stuff, but you should have been able to find this in ANY beginner book on
ASP.Net stuff. You should get and read one of um...
<les> wrote in message news:s0********************************@4ax.com... I'm new to asp.net. (refugee from old asp) I have a database field "Website", which is a url and I want it be a hyperlink. I can display the url as text using:
<asp:literal id="litWebsite" runat="server"></asp:literal>
But I want it to be a hyperlink. I tried enclosing the above line in an <a href......> tag but no good.
Any tips for a newbie?? Thanks Leslie
Thanks David, but believe me I have searched everywhere for this!
Maybe its so basic that I can't see it. I managed to include links in
datagrid pages with no problem, but this is doing my head in.
The code here shows my data on the page sucessfully, but could you
show me how I amend it to show the link. Also, some fields are long
text with carriage returns. How do I show these properly formatted?
Thanks again
Leslie
=============================
<script runat="server">
Sub Page_Load (sender As Object, e As EventArgs)
Dim conn As OleDbConnection
Dim cmd As OleDbCommand
Dim rdr As OleDbDataReader
Dim strId As String
Dim strSQL As String
strId = Request.QueryString("id")
Conn = New OleDbConnection ("PROVIDER=SQLOLEDB;
server=servername;database=briefings;User Id=;Password=;")
Conn.open
strSQL = "SELECT * FROM Briefings WHERE id = " & strId & " "
cmd = New OleDbCommand(strSQL, conn)
rdr = cmd.ExecuteReader
If rdr.Read Then
litid.Text = rdr.Item("id")
litTitle.Text = rdr.Item("Title")
litEmail.Text = rdr.Item("Email")
litAddDate.Text = Format(rdr.Item("AddDate"), "dd-MMM-yyyy")
litContact.Text = rdr.Item("Contact")
litDetails.Text = rdr.Item("Details")
litAuthor.Text = rdr.Item("Author")
litWebsite.Text = rdr.Item("Website")
Else
litID.Text = "ID '" & strId & "' not found"
End If
rdr.Close
cmd.Dispose
conn.Close
End Sub
</script>
================================
Then in the html:
<asp:literal id="litWebsite" runat="server"></asp:literal>
================================
On Sat, 05 Jul 2003 23:53:02 GMT, "David Waz..." <dl*@pickpro.com>
wrote: uh, no that's not how to do it! :-)
<asp:LinkButton id="link1" runat=server />
then, in your code-behind:
at top: Protected link1 as LinkButton
and finally, within your code - one way to do this:
link1.text=o_dataRow.item("WebSite")
That's it...
PS: this is pretty basic stuff, not complicated. Glad to answer this kind of stuff, but you should have been able to find this in ANY beginner book on ASP.Net stuff. You should get and read oneofum...le************************************** ***************@4ax.zl6...I'mnewtoasp.net.refugeef romoldaspIhaveadatabasefieldWebsite,whichisaurland Iwantitbeahyperlink.Icandisplaytheurlastextusingas pliteral id="litWebsite" runat="server"></asp:literal> But I want it to be a hyperlink. I tried enclosing the above line in an <a href......> tag but no good.
Any tips for a newbie?? Thanks Leslie
Thanks. I found another way to do it using:
litWebsite.text = "<A HREF='" + rdr.Item("Website") + "'>" +
rdr.Item("Website") + "</A>"
and in the html:
<asp:literal id="litWebsite" runat="server"></asp:literal>
But I will keep your answer for next time :)
By the way I already have a book: "Web database development step by
step" by Jim Buyens. I have found it very useful, having come from
asp, just starting out with .net. Also I just discovered Web Matrix
which is good for editing.
Thanks again
Leslie
On Sun, 06 Jul 2003 17:27:30 GMT, "David Waz..." <dl*@pickpro.com>
wrote: I understand.. (get the book anyway! ;)
I really did answer this last time... I'm assuming you have litTitle as labels or literal controls on your page. IE: <asp:Label id=litEmail>... <asp:label id=litDetails>... <asp:Label id="litWebSite">...
Well, REMOVE the current control for the WEBSITE field, and replace it with: <asp:LinkButton id="linkWebSite" runat=server >Not Found</asp:LinkButton>
Then in the code behind: If rdr.Read Then litid.Text = rdr.Item("id") litTitle.Text = rdr.Item("Title") litEmail.Text = rdr.Item("Email") litAddDate.Text = Format(rdr.Item("AddDate"), "dd-MMM-yyyy") litContact.Text = rdr.Item("Contact") litDetails.Text = rdr.Item("Details") litAuthor.Text = rdr.Item("Author") linkWebSite.Text = rdr.Item("Website")
That should do it... let us all know which book you picked!
<les> wrote in message news:b5********************************@4ax.com... Thanks David, but believe me I have searched everywhere for this! Maybe its so basic that I can't see it. I managed to include links in datagrid pages with no problem, but this is doing my head in.
The code here shows my data on the page sucessfully, but could you show me how I amend it to show the link. Also, some fields are long text with carriage returns. How do I show these properly formatted? Thanks again Leslie
=============================
<script runat="server"> Sub Page_Load (sender As Object, e As EventArgs) Dim conn As OleDbConnection Dim cmd As OleDbCommand Dim rdr As OleDbDataReader Dim strId As String Dim strSQL As String strId = Request.QueryString("id")
Conn = New OleDbConnection ("PROVIDER=SQLOLEDB; server=servername;database=briefings;User Id=;Password=;") Conn.open
strSQL = "SELECT * FROM Briefings WHERE id = " & strId & " " cmd = New OleDbCommand(strSQL, conn) rdr = cmd.ExecuteReader If rdr.Read Then litid.Text = rdr.Item("id") litTitle.Text = rdr.Item("Title") litEmail.Text = rdr.Item("Email") litAddDate.Text = Format(rdr.Item("AddDate"), "dd-MMM-yyyy") litContact.Text = rdr.Item("Contact") litDetails.Text = rdr.Item("Details") litAuthor.Text = rdr.Item("Author") litWebsite.Text = rdr.Item("Website")
Else litID.Text = "ID '" & strId & "' not found" End If rdr.Close cmd.Dispose conn.Close End Sub
</script> ================================
Then in the html: <asp:literal id="litWebsite" runat="server"></asp:literal>
================================
On Sat, 05 Jul 2003 23:53:02 GMT, "David Waz..." <dl*@pickpro.com> wrote:
>uh, no that's not how to do it! :-) > ><asp:LinkButton id="link1" runat=server /> > >then, in your code-behind: > >at top: >Protected link1 as LinkButton > >and finally, within your code - one way to do this: > >link1.text=o_dataRow.item("WebSite") > >That's it... > >PS: this is pretty basic stuff, not complicated. Glad to answer thiskind >of stuff, but you should have been able to find this in ANY beginner bookon >ASP.Net stuff. You should get and readoneofum...le************************************* ****************@4ax.zl6... I'mnewtoasp.net.refugeefromoldaspIhaveadatabasefi eldWebsite,whichisaurlandIw antitbeahyperlink.Icandisplaytheurlastextusingasp literal id="litWebsite" runat="server"></asp:literal> >> >> But I want it to be a hyperlink. I tried enclosing the above line in >> an <a href......> tag but no good. >> >> Any tips for a newbie?? >> Thanks >> Leslie >
That'll work - but it's ugly! (MHO) ;-)
I wish you would try the .Net way - you'll learn something new, and not get
into bad habits.
<les> wrote in message news:0g********************************@4ax.com... Thanks. I found another way to do it using:
litWebsite.text = "<A HREF='" + rdr.Item("Website") + "'>" + rdr.Item("Website") + "</A>"
and in the html: <asp:literal id="litWebsite" runat="server"></asp:literal>
But I will keep your answer for next time :)
By the way I already have a book: "Web database development step by step" by Jim Buyens. I have found it very useful, having come from asp, just starting out with .net. Also I just discovered Web Matrix which is good for editing.
Thanks again Leslie
On Sun, 06 Jul 2003 17:27:30 GMT, "David Waz..." <dl*@pickpro.com> wrote:
I understand.. (get the book anyway! ;)
I really did answer this last time... I'm assuming you have litTitle as labels or literal controls on your
page.IE: <asp:Label id=litEmail>... <asp:label id=litDetails>... <asp:Label id="litWebSite">...
Well, REMOVE the current control for the WEBSITE field, and replace it
with:<asp:LinkButton id="linkWebSite" runat=server >Not Found</asp:LinkButton>
Then in the code behind: If rdr.Read Then litid.Text = rdr.Item("id") litTitle.Text = rdr.Item("Title") litEmail.Text = rdr.Item("Email") litAddDate.Text = Format(rdr.Item("AddDate"), "dd-MMM-yyyy") litContact.Text = rdr.Item("Contact") litDetails.Text = rdr.Item("Details") litAuthor.Text = rdr.Item("Author") linkWebSite.Text = rdr.Item("Website") That should do it... let us all know which book you picked!
<les> wrote in message news:b5********************************@4ax.com... Thanks David, but believe me I have searched everywhere for this! Maybe its so basic that I can't see it. I managed to include links in datagrid pages with no problem, but this is doing my head in.
The code here shows my data on the page sucessfully, but could you show me how I amend it to show the link. Also, some fields are long text with carriage returns. How do I show these properly formatted? Thanks again Leslie
=============================
<script runat="server"> Sub Page_Load (sender As Object, e As EventArgs) Dim conn As OleDbConnection Dim cmd As OleDbCommand Dim rdr As OleDbDataReader Dim strId As String Dim strSQL As String strId = Request.QueryString("id")
Conn = New OleDbConnection ("PROVIDER=SQLOLEDB; server=servername;database=briefings;User Id=;Password=;") Conn.open
strSQL = "SELECT * FROM Briefings WHERE id = " & strId & " " cmd = New OleDbCommand(strSQL, conn) rdr = cmd.ExecuteReader If rdr.Read Then litid.Text = rdr.Item("id") litTitle.Text = rdr.Item("Title") litEmail.Text = rdr.Item("Email") litAddDate.Text = Format(rdr.Item("AddDate"), "dd-MMM-yyyy") litContact.Text = rdr.Item("Contact") litDetails.Text = rdr.Item("Details") litAuthor.Text = rdr.Item("Author") litWebsite.Text = rdr.Item("Website")
Else litID.Text = "ID '" & strId & "' not found" End If rdr.Close cmd.Dispose conn.Close End Sub
</script> ================================
Then in the html: <asp:literal id="litWebsite" runat="server"></asp:literal>
================================
On Sat, 05 Jul 2003 23:53:02 GMT, "David Waz..." <dl*@pickpro.com> wrote:
>uh, no that's not how to do it! :-) > ><asp:LinkButton id="link1" runat=server /> > >then, in your code-behind: > >at top: >Protected link1 as LinkButton > >and finally, within your code - one way to do this: > >link1.text=o_dataRow.item("WebSite") > >That's it... > >PS: this is pretty basic stuff, not complicated. Glad to answer this kind >of stuff, but you should have been able to find this in ANY beginner
bookon >ASP.Net stuff. You should get and read oneofum...le************************************* ****************@4ax.zl6..
.. I'mnewtoasp.net.refugeefromoldaspIhaveadatabasefi eldWebsite,whichisaurlandI
wantitbeahyperlink.Icandisplaytheurlastextusingasp literal id="litWebsite" runat="server"></asp:literal> >> >> But I want it to be a hyperlink. I tried enclosing the above line in >> an <a href......> tag but no good. >> >> Any tips for a newbie?? >> Thanks >> Leslie >
You could do something along those lines if you made, say, a datatable a
static member. That's key -- has to be static to be callable:
<%=this.StaticDataTable.Rows[0]["Website"].ToString()%> or something like
that...
Or make the row static:
<%=this.StaticRow["Website"].ToString()%>
So your accessors would look like this:
public static DataTable StaticDataTable()
{
// Load your data, returning the datatable.
}
public static DataRow StaticRow()
{
// Load your data, get the row and return it.
}
But I don't think you could do it with a reader. Anyone correct me if I'm
wrong on that.
If you're looking for something that repeats, and will accept your
formatting and the like given a datareader, take a look at the Repeater web
control.
Luck!
<les> wrote in message news:cs********************************@4ax.com... I'm a bit lost here! What I need to do is the asp.net equivalent of:
<a href="<%=rs(Website")%>"><%=rs("Website")%></a>
How would I do that? Thanks Leslie
On Sat, 5 Jul 2003 17:56:29 -0700, "Steve C. Orr, MCSD" <St***@Orr.net> wrote:
Well it could be as simple as this: <asp:literal id="litWebsite" runat="server"><a href='whatever.aspx'>click here</a></asp:literal>
Or you could put a hyperlink web server control in there, etc.
You could do something along those lines if you made, say, a datatable a
static member. That's key -- has to be static to be callable:
<%=this.StaticDataTable.Rows[0]["Website"].ToString()%> or something like
that...
Or make the row static:
<%=this.StaticRow["Website"].ToString()%>
So your accessors would look like this:
public static DataTable StaticDataTable()
{
// Load your data, returning the datatable.
}
public static DataRow StaticRow()
{
// Load your data, get the row and return it.
}
But I don't think you could do it with a reader. Anyone correct me if I'm
wrong on that.
If you're looking for something that repeats, and will accept your
formatting and the like given a datareader, take a look at the Repeater web
control.
Luck!
<les> wrote in message news:cs********************************@4ax.com... I'm a bit lost here! What I need to do is the asp.net equivalent of:
<a href="<%=rs(Website")%>"><%=rs("Website")%></a>
How would I do that? Thanks Leslie
On Sat, 5 Jul 2003 17:56:29 -0700, "Steve C. Orr, MCSD" <St***@Orr.net> wrote:
Well it could be as simple as this: <asp:literal id="litWebsite" runat="server"><a href='whatever.aspx'>click here</a></asp:literal>
Or you could put a hyperlink web server control in there, etc. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Thubaiti |
last post by:
Hi,
I have this code:
<td>
<a href="#" class="toolbar">Computers</a>
<a href="commun.html" class="toolbar">Communications</a>
<a href="electronics.html" class="toolbar">Electronics</a>
<a...
|
by: Kevin Quigley |
last post by:
Hi,
I have a datalist which has an EditItemTemplate section, within this I
have a hyperlink control with which I want to open a new window with
some help details.
This is the hyperlink code:...
|
by: Amir Eshterayeh |
last post by:
Dear Friends
My asp hyperlink goes to relative address instead of absolute. I like
navigate url goes to outsite link like www.asp.net but now, it goes to
www.mysite/www.asp.net
please help....
|
by: James P. |
last post by:
Hello there,
I have an asp hyperlink in a template page. In my user control page -
code behind page that uses the template, I'd like to turn this link
invisible in certain case. Is it...
|
by: Martin Dew |
last post by:
Having some problems getting a hyperlink object to work in my repeater
control, It displays the text I have asked it to for the hyperlink, but it
does not act as a link. My repeater code is below...
|
by: Leon |
last post by:
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks.
<asp:datalist id="DataList1" runat="server"
RepeatColumns="4">
<ItemTemplate>
<asp:HyperLink
id=HyperLink1
ImageUrl=...
|
by: Satya |
last post by:
Hi all,
The following code is throwing a run time error "The server tag is not well
formed.
"
<ItemTemplate>
<asp:HyperLink Runat="server" ID="lnkFile"...
|
by: dana lees |
last post by:
Hello,
I am using asp:HyperLink in a c# asp.net application to open a new window in
the following way:
<asp:HyperLink ID="lnkSiteName" runat="server" Text='<%#
DataBinder.Eval(Container,...
|
by: nicknack |
last post by:
Hello.
I have an asp:hyperling in my page and I'm trying to make it "clicked"
from my code behind.
Is this possible?
I also tried it with JS but its look like the hyperlink doesn't have a...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |