Only display div in template when no querystring present
Hi,
I have a website homepage which contains a div containing general content and a list of news items which are paginated. I want to display the general content div only when the user is on the first page i.e. when there's no querystring variable or when the querystring is 'page=1'.
Is it possible to insert some inline C# to do this, or is there a better way?
The code I have in the template is currently like this:
Dirk, your solution works when there's no variable, but I also need it to work when the querystring value is 1. I've tried this, but just get an error:
<% if ((string.IsNullOrEmpty(Request.QueryString["page"])) || (Request.QueryString["page"].ToString() != '1')){ %>
The error is something to do with the data types of the requested string and the comparitor:
"CS0019:
Operator '!=' cannot be applied to operands of type 'string' and 'char'"
Only display div in template when no querystring present
Hi,
I have a website homepage which contains a div containing general content and a list of news items which are paginated. I want to display the general content div only when the user is on the first page i.e. when there's no querystring variable or when the querystring is 'page=1'.
Is it possible to insert some inline C# to do this, or is there a better way?
The code I have in the template is currently like this:
Thanks for any pointers...
Hi Dan,
Hope this helps.
Regards,
/Dirk
In XSLT it is:
Thanks Dirk & Thomas.
Dirk, your solution works when there's no variable, but I also need it to work when the querystring value is 1. I've tried this, but just get an error:
The error is something to do with the data types of the requested string and the comparitor:
"CS0019: Operator '!=' cannot be applied to operands of type 'string' and 'char'"
Can you see why this is erroring?
'1' is a character not an string so you have to cast:
hth, Thomas
btw: the
so you dont need to cast this ;-)
Or just use "1" instead of '1'.ToString()
And again learned a small detail...
never thought about this...
thx Dirk
is working on a reply...