Hi dipabali,
Refer the below sample.
Index.aspx
<asp:DropDownList ID="ddlLocations" runat="server">
<asp:ListItem Value="0">--SELECT--</asp:ListItem>
<asp:ListItem Value="1">Kolkata</asp:ListItem>
<asp:ListItem Value="2">Bangalore</asp:ListItem>
<asp:ListItem Value="3">Mumbai</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btnSubmit" runat="server" OnClick="SubmitClick" Text="Submit" />
Index.aspx.cs
protected void SubmitClick(object sender, EventArgs e)
{
if (Convert.ToInt32(ddlLocations.SelectedValue) > 0)
{
Server.Transfer("NextPage.aspx?City=" + ddlLocations.SelectedItem.Text.Trim());
}
else
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "", "alert('Please Select City')", true);
}
}
Index.aspx.vb
Protected Sub SubmitClick(sender As Object, e As EventArgs)
If Convert.ToInt32(ddlLocations.SelectedValue) > 0 Then
Server.Transfer("NextPage.aspx?City=" + ddlLocations.SelectedItem.Text.Trim())
Else
ClientScript.RegisterClientScriptBlock(Me.[GetType](), "", "alert('Please Select City')", True)
End If
End Sub
NextPage.aspx
<asp:Label ID="lblMessage" runat="server" />
NextPage.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["City"] != null || Request.QueryString["City"] != "")
{
lblMessage.Text = "It is " + Request.QueryString["City"];
}
}
NextPage.aspx.vb
Protected Sub Page_Load(sender As Object, e As EventArgs)
If Request.QueryString("City") IsNot Nothing OrElse Request.QueryString("City") <> "" Then
lblMessage.Text = "It is " + Request.QueryString("City")
End If
End Sub