Bikram
Bikram

Reputation: 197

read a id from Request.QueryString

hello im tying to read id from Request.QueryString in html tage in asp.net but it can work and read a velue by Request.QueryString from url. here is a code which i used below

<video src='<%# "VideoHandler.ashx?id=" + Request.QueryString["id"] ' width="220" 
height="200" controls="" preload=""></video>

please let me know how can i bid this in fount hand tag in asp.net

Upvotes: 1

Views: 1089

Answers (2)

Smeegs
Smeegs

Reputation: 9224

First, you need to close your server tag

<video src='<%# "VideoHandler.ashx?id=" + Request.QueryString["id"] %>' width="220" 
height="200" controls="" preload=""></video>

Second...

I've always found it easier to add this to a protected function in the code behind and call the function in the mark up.

So (assuming c#) I would have

protected string getHandler(){
     return "VideoHandler.ashx?id=" + Server.UrlEncode(Request.QueryString["id"]);
}

Then in the markup just have

<video src='<%# getHandler() %> ' width="220" 
height="200" controls="" preload=""></video>

Upvotes: 1

bluetoft
bluetoft

Reputation: 5443

You forgot to close your server side tag and you shouldn't have your string in your tag. src property should look like so:

VideoHandler.ashx?id=<%# Request.QueryString["id"] %>

Upvotes: 0

Related Questions