0

I am trying to pass query string value on clicking any hyperlink which are dnamically generated. Something like this..

<%
------some code----
 clickedalbum = dt6.Rows[0]["albumid"].ToString();

  %> 
      <asp:HyperLink ID="HyperLink1" runat="server" href="attendance1.aspx?albumid=<%#clickedalbum %>" >
SamuraiJack
  • 5,131
  • 15
  • 89
  • 195

4 Answers4

1

I got it figured out, the problem was that i was using server control. Using
<a href='attendance1.htm?albumid=<%=clickedalblum%>'>--some stuff--</a> Solved the problem. Thanks everyone for their response specially Ratna.

SamuraiJack
  • 5,131
  • 15
  • 89
  • 195
0

Do it from code behind in load event as

HyperLink1.NavigateUrl = "attendance1.aspx?albumid=" + clickedalbum;

ok do it as follows:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="test.aspx.cs" Inherits="test" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:HyperLink ID="HyperLink1" runat="server"  NavigateUrl='<%#clickedalbum %>' Text="Testlink"></asp:HyperLink>
</div>
</form>
</body>
</html>

In the code behind:

using System;

public partial class test : System.Web.UI.Page
{
 public string clickedalbum = "";
protected void Page_Load(object sender, EventArgs e)
{
     clickedalbum = "attendance1.aspx?albumid=123";
     DataBind();
}
}

For details visit this link Why will <%= %> expressions as property values on a server-controls lead to a compile errors?

Community
  • 1
  • 1
Ratna
  • 2,289
  • 3
  • 26
  • 50
0

use like this

href='<%# "attendance1.aspx?albumid="+clickedalbum %>'
dreamcrash
  • 47,137
  • 25
  • 94
  • 117
Sain Pradeep
  • 3,119
  • 1
  • 22
  • 31
0
NavigateUrl='<%# Eval("clickedalbum ","~/attendance1.aspx?albumid={0}") %>'
Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83