Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2010-08-25
3
Medium Priority
?
736 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
[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
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 2000 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

670 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