nightingale
nightingale

Reputation: 5

response redirect from one page to another in asp.net

i have 2 pages, the first page user have to select radiobuttonlist , select 2 calendar date and fill the textbox. thus the 2nd page have to display all of it, but theres no fetch. when i run the program, there are no errors.

these are from the first page back code.

protected void lbnext_Click(object sender, EventArgs e)
{
    ValidateEmail();
    ValidateDate();

    if (lwarndate.Visible == false &&
        lwarnemail.Visible == false)
    {
        Response.Redirect("~/Staff/ApplyLeaveConfirm.aspx?qsLeaveCode=" + rblleavetype.SelectedValue.ToString() +
                          "&qsLeaveType=" + rblleavetype.SelectedItem.ToString() +
                          "&qsStartDate=" + lstartdate.Text +
                          "&qsEndDate=" + lenddate.Text +
                          "&qsReason=" + tbreason.Text +
                          "&qsValue=" + total.Text +
                          "&qsSV=" + tbsvemail.Text);

    }
}

these are the 2nd page back code.

    protected void Page_Load(object sender, EventArgs e)
{
    if (Session["ID"] == null)
    {
        Response.Redirect("~/Default.aspx");
    }
    if (Session["ID"] != null)
    {
        string id = Session["ID"].ToString();
        sqluser.SelectCommand =
            "SELECT id, name, email " +
            "FROM   profile " +
            "WHERE  id='" + id + "'";

        sqluser.DataBind();

        if (Request.QueryString["qsLeaveCode"] != null &&
            Request.QueryString["&qsLeaveType"] != null &&
            Request.QueryString["&qsStartDate"] != null &&
            Request.QueryString["&qsEndDate"] != null &&
            Request.QueryString["&qsReason"] != null &&
            Request.QueryString["&qsValue"] != null &&
            Request.QueryString["&qsSV"] != null
            )
        {
            lleavetypecode.Text = Request.QueryString["qsLeaveCode"].ToString();
            lleavetype.Text = Request.QueryString["&qsLeaveType"].ToString();
            lstartdate.Text = Request.QueryString["&qsStartDate"].ToString();
            lenddate.Text = Request.QueryString["&qsEndDate"].ToString();
            lleavetype1.Text = Request.QueryString["&qsLeaveType"].ToString();
            lreason.Text = Request.QueryString["&qsReason"].ToString();
            ltotalleavetype.Text = Request.QueryString["&qsValue"].ToString();
            lsvemail.Text = Request.QueryString["&qsSV"].ToString();
        }

        if (!Page.IsPostBack)
        {
            DataView dv = (DataView)sqluser.Select(DataSourceSelectArguments.Empty);

            foreach (DataRow dr in dv.Table.Rows)
            {
                lname.Text = dr["name"].ToString();
                lemail.Text = dr["email"].ToString();
            }
        }
    }
}

im quite new in c# so forgive me if for my explaining deficiency.

Upvotes: 0

Views: 830

Answers (1)

Mikhail Timofeev
Mikhail Timofeev

Reputation: 2169

u don't need a "&" symbol in if-check and later. QueryStrings are stored without "&"

   if (Request.QueryString["qsLeaveCode"] != null &&
        Request.QueryString["qsLeaveType"] != null &&
        Request.QueryString["qsStartDate"] != null &&
        Request.QueryString["qsEndDate"] != null &&
        Request.QueryString["qsReason"] != null &&
        Request.QueryString["qsValue"] != null &&
        Request.QueryString["qsSV"] != null
      ){
        lleavetypecode.Text = Request.QueryString["qsLeaveCode"].ToString();
        lleavetype.Text = Request.QueryString["qsLeaveType"].ToString();
        lstartdate.Text = Request.QueryString["qsStartDate"].ToString();
        lenddate.Text = Request.QueryString["qsEndDate"].ToString();
        lleavetype1.Text = Request.QueryString["qsLeaveType"].ToString();
        lreason.Text = Request.QueryString["qsReason"].ToString();
        ltotalleavetype.Text = Request.QueryString["qsValue"].ToString();
        lsvemail.Text = Request.QueryString["qsSV"].ToString();
       }

Upvotes: 2

Related Questions