How can I redirect based on a selection of a DropDownList
I have a TextBox1
and a Search button in my application with this following code:
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("~\\searchpage.aspx?PatientNRIC=" + TextBox1.Text);
}
Which means, if the user type ONLY IC NO:S1234567D
, then when click it will show the patient detailview.
So I now I'm doing almost the same thing but now I have a TextBox开发者_StackOverflow2
and a DropDownList1
. Inside DropDownList1
, I have "Name", "IC No", "Test_Date".
So for an example, I type "S1234567D" in the textbox1, and I choose "IC No" in DropDownList1
it should redirect me to a page of the S1234567D's patient detailview.
How could I do my code? Thanks!
Something like the following might work for you:
protected void Button1_Click(object sender, EventArgs e)
{
if(dropdownlist1.SelectedValue == "IC No")
{
// assuming this is the redirect to your patients details view
// but you MUST use only forward slashes to make it work (!)
Response.Redirect("~/searchpage.aspx?PatientNRIC=" + TextBox1.Text);
}
}
name.Text = ddl1.DataTextField;
ICNo.Text = ddl1.DataValueField;
textBox1.Text = name.text+ICno.Text;
protected void Button1_Click(object sender, EventArgs e) {
if(textbox1 != null) { Response.Redirect("~/searchpage.aspx?PatientNRIC=" + TextBox1.Text); } } }
精彩评论