Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8545147
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:43:35+00:00 2026-06-11T12:43:35+00:00

//master.cs protected void ddlLanguage_SelectedIndexChanged(object sender, EventArgs e) { //alert box string message = Some

  • 0
//master.cs     
protected void ddlLanguage_SelectedIndexChanged(object sender, EventArgs e)
    {
    //alert box
            string message = "Some Content of the Site are only in English. Do you want to continue?";
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append("return confirm('");
            sb.Append(message);
            sb.Append("');");
            Page.ClientScript.RegisterOnSubmitStatement(this.GetType(), "alert", sb.ToString());
       //alert end
            //Sets the cookie that is to be used by Global.asax
            HttpCookie cookie = new HttpCookie("CultureInfo");
            cookie.Value = ddlLanguage.SelectedValue;
            Response.Cookies.Add(cookie);

            //Set the culture and reload the page for immediate effect. 
            //Future effects are handled by Global.asax
            Thread.CurrentThread.CurrentCulture = new CultureInfo(ddlLanguage.SelectedValue);
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ddlLanguage.SelectedValue);
            Server.Transfer(Request.Path);
    }

//master  Page
<asp:DropDownList ID="ddlLanguage" class="langpnl" runat="server" AutoPostBack="True" 
        OnSelectedIndexChanged="ddlLanguage_SelectedIndexChanged">
        <asp:ListItem Value="en-US">Eng</asp:ListItem>
        <asp:ListItem Value="es-ES">Esp</asp:ListItem>
    </asp:DropDownList>

Whenever the user changes from English to Spanish I want to display an alert box.
Its a weird behavior, this code is not working its not showing me any alert box on selected index change but if I paste the alert box code in the page load event it works. Is the pageload has to do anything with this?
Secondly is it possible to remember the answer i.e if the user selects an checkbox saying remember me, I should remember whether the user selected YES or NO throughout the session.
any suggestions on the second questions will help. But please help me find the reason why the above code is not working as expected.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T12:43:36+00:00Added an answer on June 11, 2026 at 12:43 pm

    Try the following code in your dropdownSelected index changed event to show the alert box

    if (!ClientScript.IsStartupScriptRegistered("JSScript"))
                {
                    //give the exception details in a alert box
                    string sb = string.Format(@"<script>alert('{0}');</script>'", "Message to be shown");
                    ClientScript.RegisterStartupScript(this.GetType(), "JSScript", sb);
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a master page with the following code: protected void Page_Init(object sender, EventArgs
I put a break point at the protected void Page_Load(object sender, EventArgs e) method
Im setting the the datasource with the following code: protected void Page_Load(object sender, EventArgs
Here is my OnClick event: protected void Submit_Click(object sender, EventArgs e) { try {
I'm using this code to change the applications theme protected void Page_PreInit(object sender, EventArgs
Here is the code behind: protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { DetailsView1.Visible =
Here is my code that runs on page load: protected void Page_Load(object sender, EventArgs
Here is a code sample: myMaster.Master <asp:LinkButton runat=server OnClick=anAction_Click> calls: myMaster.Master.cs protected void anAction_Click(object
In the following master.cs code: public partial class Default : System.Web.UI.MasterPage { protected void
it is very easy to access master page control from content page like protected

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.