Solved

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

Posted on 2010-08-25
3
685 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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

17 Experts available now in Live!

Get 1:1 Help Now