I want to display:none
html element in asp.net something like this :)
<ul style="<% if(Page.Request.QueryString["Search"] == null) { "display: none"} %>">
Any suggestion or example would be great for me, thanks.
I want to display:none
html element in asp.net something like this :)
<ul style="<% if(Page.Request.QueryString["Search"] == null) { "display: none"} %>">
Any suggestion or example would be great for me, thanks.
what about
<% = (Page.Request.QueryString["Search"] == null ? "display:none":string.Empty) %>
Why not use javascript for this? It will be much cleaner to keep client side code separate.
there are a ton of ways to get a query string in JS here is one
Then you can check and add the class with jquery.
HTML:
<ul id="search">
<li>test</li>
</ul>
Javascript:
// from https://stackoverflow.com/questions/4656843/jquery-get-querystring-from-url
function getUrlVars()
{
var vars = [], hash;
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
for(var i = 0; i < hashes.length; i++)
{
hash = hashes[i].split('=');
vars.push(hash[0]);
vars[hash[0]] = hash[1];
}
return vars;
}
var search = getUrlVars()["Search"];
if(!search)
{
$("#search").css("display","none")
}