Solved

Passing an ID to a request query string using an asp.net Hyperlink object

Posted on 2010-08-25
3
698 Views
Last Modified: 2012-05-10
I have a repeater that links a series of news stories from a database.  I am trying to pass the ID field through a Hyperlink Object:

<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# string.Format("News_Details.aspx?ID={0}", Eval("PKID") ) %>' Text='<%# DataBinder.Eval(Container.DataItem,"Headline") %>' />
        </strong>

The problem I am having is I am not getting a value from the second page in the code behind:

  Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim NewsID As String
        NewsID = Page.Request.QueryString("News_Details.aspx?ID=" & ID)
        If Request.QueryString("News_Details.aspx?ID=" & ID) <> Nothing Then
            MsgBox(NewsID.ToString)
        End If

End Sub
0
Comment
Question by:thomashospital
3 Comments
 
LVL 10

Expert Comment

by:Jini Jose
ID: 33523596
use simple <a href> instead of asp:hyperlinks
check the below code

<a title='<%# Eval("Title") %>' href='ShowNews.aspx?Id=<%# Eval("Id") %>'> <%# Eval("Title")%>
0
 
LVL 6

Accepted Solution

by:
Aksh earned 500 total points
ID: 33523690
Hi,

I think, the way you are retrieving the query string in second page is not appropriate.

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Request.QueryString("ID") Is Nothing Then
             Dim NewsID As String = CType(Request.QueryString("ID"), String)
             Response.Write(NewsID)
        Else
             Response.Write("Problem with the first page: No QueryString sent!")
        End If
End Sub

-Aksh
0
 

Author Closing Comment

by:thomashospital
ID: 33523871
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with solving error related to resources file 4 36
vb.net checkbox 7 41
SQL Login 17 41
Error "String or binary data would be truncated" in an update on a datatable 7 29
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

863 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

19 Experts available now in Live!

Get 1:1 Help Now