Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
Hi Experts !
 
my project is based on Asp.Net c#
 
In this Project, I have 3 login pages, which must be redirected from dropdownlist. if user selected.
 
I want to redirect these pages using Query String.
 
This is my dropdownlist design and code.
 
<asp:DropDownList ID="DDLCollegeSelection" runat="server" Width="250px" AutoPostBack="true" CssClass="DropdownCSS"
                                onselectedindexchanged="DDLCollegeSelection_SelectedIndexChanged">
 <asp:ListItem>---- Select College----</asp:ListItem>
<asp:ListItem>Siddharta Engineering College</asp:ListItem>
<asp:ListItem>Shadan Engineering College</asp:ListItem>
<asp:ListItem>Hipoint Engineering College</asp:ListItem>
 </asp:DropDownList>
 

 

protected void DDLAirportSelection_SelectedIndexChanged(object sender, EventArgs e)
    {
if (DDLCollegeSelection.SelectedItem.Value == "Siddharta Engineering College")
        {
            Response.Redirect("SiddhartaLogin.aspx");
        }
 
        else if (DDLCollegeSelection.SelectedItem.Value == "Shadan Engineering College")
        {
 
            Response.Redirect("ShadanLogin.aspx");
        }
 
        else if(DDLCollegeSelection.SelectedItem.Value == "HiPoint Engineering College");
        {
            Response.Redirect("HIPointLogin.aspx");
        }
    }
 

 
I also Inclduded NameSpace as.... using System.Collections.Generic;
 

So, My requirement is I need a QueryString to redirect the pages... so that i can see the Querystring in Browser area.
 

Please help me Thanks.
Posted 16-Feb-13 19:06pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

try this:
protected void DDLAirportSelection_SelectedIndexChanged(object sender, EventArgs e)
    {
if (DDLCollegeSelection.SelectedItem.Value == "Siddharta Engineering College")
        {
            Response.Redirect("SiddhartaLogin.aspx?Querystring=Siddharta");
        }
 
        else if (DDLCollegeSelection.SelectedItem.Value == "Shadan Engineering College")
        {
 
            Response.Redirect("ShadanLogin.aspx?Querystring=Shadan");
        }
 
        else if(DDLCollegeSelection.SelectedItem.Value == "HiPoint Engineering College");
        {
            Response.Redirect("HIPointLogin.aspx?Querystring=HiPoint");
        }
    }
and in goal page use this in page load event :
string Querystring=Request.QueryString["Querystring"].toString();
with an if statement ,check Querystring and do any operation you want .
 
In Addition :
if you have 2 or more data to send as querystring, use & between any querystring variable;
you cant use space between words in querystring so use 20% or + or use fit encoding .
in our example you can use another name instead of Querystring as querystring field.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

I also Inclduded NameSpace as.... using System.Collections.Generic;
What for? Not needed for query string.
 
Not exactly sure on what you want to use query string for, just in case of how to pass and use query strings, look here:
Passing variables between pages using QueryString[^]
How to use Querystring[^]
 

Have a first page with dropdown and based on it direct to other page.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Please check if any code issue there.
<blockquote class="FQ"><div class="FQA">Quote:</div><asp:ListItem Text = "---- Select College----" Value="0" />
   <asp:ListItem Text = "Siddharta Engineering College" Value="Siddharta" />
   <asp:ListItem Text = "Shadan Engineering College" Value="Shadan" />
   <asp:ListItem Text = "Hipoint Engineering College" Value="Hipoint" /></blockquote>
 
 
            switch (DDLCollegeSelection.SelectedValue.ToLower())
            {
                case "siddharta":
                    Response.Redirect("~/SiddhartaLogind.aspx?value=" + DDLCollegeSelection.SelectedValue );
                    break;
               case "shadan":
Response.Redirect("~/ShadanLogin.aspx?value=" + DDLCollegeSelection.SelectedValue);
break;
case "hipoint":
Response.Redirect("~/HIPointLogin.aspx?value=" + DDLCollegeSelection.SelectedValue);
break;
            }
Dont foget to give me points.
Thanks
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid