I just started learning asp .net yesterday and I had a question regarding the following code:
In the line:
I'm not sure how the select box is being populated through the Response.Write("selected")
How does "selected" represent the array of string values?
I hope I wasn't too confusing. Thanks for any help you can give me.
"Pin me. Perl me."
Regards,
Chris
Code:
<%@ Page Language="C#" %>
<html>
<head>
<link rel="stylesheet"href="intro.css">
</head>
<body><!-- #include File="C:\Inetpub\[URL unfurl="true"]wwwroot\DotNetJunkies\DotNetJunkiesWeb\_js\omni.inc"[/URL] -->
<center>
<form action="intro3.aspx">
<h3> Name: <input name="Name" type=text value="<%=HttpUtility.HtmlEncode(Request.QueryString["Name"])%>">
Category: <select name="Category" size=1>
<%
String [] values = { "psychology", "business", "popular_comp" };
for (int i=0; i<values.Length; i++) {
%>
<option <% if (Request.QueryString["Category"] == values[i]) { Response.Write("selected"); } %>>
<%=values[i]%>
</option>
<% } %>
</select>
</h3>
<input type=submit name="Lookup" value="Lookup">
<p>
<% if (Request.QueryString["Lookup"] != null) { %>
Hi <%=HttpUtility.HtmlEncode(Request.QueryString["Name"]) %>, you selected: <%=HttpUtility.HtmlEncode(Request.QueryString["Category"]) %>
<% } %>
</form>
</center>
</body>
</html>
In the line:
Code:
<option <% if (Request.QueryString["Category"] == values[i]) { Response.Write("selected"); } %>>
How does "selected" represent the array of string values?
I hope I wasn't too confusing. Thanks for any help you can give me.
"Pin me. Perl me."
Regards,
Chris