How to set a default value?

  • Thread starter Miguel Dias Moura
  • Start date
M

Miguel Dias Moura

Hi,

I am working on na ASP.NET / VB page.

When page loads I want:

City = <%#Request.QueryString("city")%>

Or if City is Empty in the URL then:

City = "London"

How can I do this?

Thanks,
Miguel
 
A

AFN

in the ASP page itself, I would display city as a literal...

<asp:Literal id="litCity" runat="server" />

and in the code-behind, like in page_load, I would do this:

If httpcontext.current.request.querystring("city") ="" then
litCity.Text = "London"
else
litCity.Text = httpcontext.current.request.querystring("city")
end if
 
L

Lars Netzel

Or on one row without any literal controls!

City = IIf(Request("city").Length = 0, "London", Request("city"))

You don't need to use QueryString if you are not having a POST variable
called "City" as well which asume is very unlikely.

Best Regards/
Lars Netzel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top