Hmm - any particular reason...?
Yes, the one I described in my original post.
Response.Write???? Is this ASP Classic, then...?
If it were ASP classic, I wouldn't keep describing it as ASP.NET in the
subject and text of my posts.
Were you just going to express disbelief, or did you have a comment?
I really have no idea what you're trying to do - once again, please show
your code...
I really think I have addressed this more than you are giving me credit for.
I'm happy to post some specific part of the code if you ask.
Otherwise, here's the page.
<%@ Page Language="C#" MasterPageFile="~/Default.master" Title="Submit PAD
File" %>
<%@ Import Namespace="SoftCircuits" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<%@ Register src="Controls/ErrorMessage.ascx" tagname="ErrorMessage"
tagprefix="uc1" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
try
{
object obj = Session["PadData"];
if (obj == null)
{
lblPrompt.Text = "Whoops! No PAD data found!";
throw new Exception("This page cannot be accessed in this context");
}
Session.Remove("PadData");
ViewState["PadData"] = obj;
PadData pad = (PadData)obj;
lblPrompt.Text = HttpUtility.HtmlEncode(String.Format("The category
\"{0}\" did" +
" not match any available categories. Please select a category for
{1}:",
pad.CategoryStr, pad.Title));
}
catch (Exception ex)
{
ErrorMessage1.SetError("Unable to initialize page", ex);
btnSubmit.Enabled = false;
}
}
}
protected void RenderList()
{
try
{
// Note: We need to render listbox manually do allow unencoded " "
Response.Write("<select size=\"20\" id=\"lstCategories\">\r\n");
Response.Write("<option selected=\"selected\" value=\"-1\"><Please
choose a category for this submission...></option>\r\n");
using (SqlDataReader rdr =
DataHelper.ExecProcDataReader("GetCategories"))
{
int category = -1;
while (rdr.Read())
{
int thiscategory = (int)rdr["CategoryID"];
if (category != thiscategory)
{
category = thiscategory;
Response.Write(String.Format("<option value=\"-1\">{0}</option>\r\n",
HttpUtility.HtmlEncode((string)rdr["Category"])));
}
Response.Write(String.Format("<option
value=\"{1}\"> {0}</option>\r\n",
HttpUtility.HtmlEncode((string)rdr["Title"]), rdr["SubcategoryID"]));
}
}
Response.Write("</select>\r\n");
}
catch (Exception ex)
{
ErrorMessage1.SetError("Unable to render category list", ex);
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
object obj = ViewState["PadData"];
if (obj == null)
throw new Exception("Page cannot be accessed in this context (cannot
find PAD data");
PadData pad = (PadData)obj;
// TODO: Continue submission
// pad.Category = lstCategory;
}
catch (Exception ex)
{
ErrorMessage1.SetError("Unable to submit PAD file", ex);
}
}
</script>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<blockquote>
<span class="head1">Select Category</span><br /><br />
<div align="justify">
<p>
<asp:Label ID="lblPrompt" runat="server" Text="Label"></asp:Label>
</p>
</div>
</blockquote>
<br />
<div class="box" style="text-align: center">
<h2>PAD File Submission</h2>
<uc1:ErrorMessage ID="ErrorMessage1" runat="server" />
<p>
Categories:<br />
<% RenderList(); %>
</p>
<p>
<asp:Button ID="btnSubmit" runat="server" Text="Submit"
onclick="btnSubmit_Click" />
</p>
</div>
</asp:Content>
Jonathan