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

  • SEARCH
  • Home
  • 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 9129615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T07:47:26+00:00 2026-06-17T07:47:26+00:00

I have a control that should prompt the user to choose either the session’s

  • 0

I have a control that should prompt the user to choose either the session’s customerId or the page’s old ViewState customerId. If the value in the viewstate does not match the value in session a jQuery modal dialog will appear. The dialog has two buttons, one should display the ViewState value and the other should display the session value. The button with the ViewState value also has a OnClientClick property. I have tested this code with a simple test page that includes only a single button and my control. The simple test page worked. When I added this control to a an existing page I could get the dialog to show but button.text (assigned in the code behind) was empty and the function for OnClientClick would not fire.

ascx

<script type="text/javascript">

    function ShowCustomerChangedModalDialog() {
        var dlg = $("#CustomerChangedModal").dialog({
            title: 'Select Customer ID',
            resizable: false,
            modal: true
        });
        dlg.parent().appendTo(jQuery("form:first"));
    };

    function changeCustomer(customerId, baseUrl) {
        $.ajax({ url: "/General/Accounts/change.account?id=" + customerId + "&admin=false", async: false });
        $("#CustomerChangedModal").dialog('close');
        return false;
    }

</script>

<div id="CustomerChangedModal" style="width: 440px; height: 250px; overflow: auto; display: none;">
    The session information has changed.
    Which account ID do you wish to use?
    <br />
    <br />
    <asp:Button ID="btnNewCustId" runat="server" OnClick="btnNewCustId_Click" />
    <asp:Button ID="btnOldCustId" runat="server" />
</div>

code behind

public partial class CustomerChanged : System.Web.UI.UserControl
{
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
        this.Page.PreLoad += Page_PreLoad;
    }

    void Page_PreLoad(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            ViewState.Add("CustID", Globals.CurrentCust.CustId);
        }
        if (IsPostBack)
        {
            Page.Validate();
            ValidateCustomerId();
        }
    }

    protected void ValidateCustomerId()
    {
        if (Convert.ToInt32(ViewState["CustID"]) != Globals.CurrentCust.CustId)
        {
            //button properties assignments
            btnOldCustId.Text += "Old AccountId\n" + ViewState["CustID"].ToString();
            btnNewCustId.Text += "New AccountId\n" + Globals.CurrentCust.CustId.ToString();
            btnOldCustId.OnClientClick = string.Format("return changeCustomer({0},'{1}');", ViewState["CustID"].ToString(), Globals.GeneralSiteUrl);

            CustomValidator err = new CustomValidator();
            err.IsValid = false;
            err.ErrorMessage = "The customer has changed.";
            Page.Validators.Add(err);
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {

        if (IsPostBack)
        {
            if (!Page.IsValid)
            {
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "CustomerChangedModalDialog", "ShowCustomerChangedModalDialog();", true);
            }
        }
    }

    protected void btnNewCustId_Click(object sender, EventArgs e)
    {
        Response.Redirect(Request.RawUrl);
    }

}

Any help would be appreciated.

  • 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-17T07:47:27+00:00Added an answer on June 17, 2026 at 7:47 am

    I stopped trying to use server side code and switched to javascript to assign the button text and to reloading the page with the new customerId. This doesn’t answer my question as to why the server side properties where not behaving as I expected but it gets the job done for now.

    var div = $("#CustomerChangedModal");
    var oldButton = $("[id$=btnOldCustId]", div);
    var newButton = $("[id$=btnNewCustId]", div);
    newButton.val("New AccountId " + newId);
    oldButton.val("Old AccountId " + oldId);
    newButton.on("click", function (event) { changeCustomerNew(newId) });
    oldButton.on("click", function (event) { changeCustomerOld(oldId) });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control that should serve as container and it looks like
I have an array of items that should be selected in my tree control.
I have a control that should display breadcrumb navigation. It needs data (route &
I have a textBox control that lets the user their email address/addresses. The use
I have a TreeView Control (that should look like this) But I don't know
I have a user control that hosts other controls. The way I implemented this
I have a custom WPF control MyLine that should represent or not some text
I have a control that look something like this: <asp:DetailsView ID=dvUsers runat=server DataSourceID=odsData DataKeyNames=Id>
I have a control that has a Filter property that expects a function that
I have a control that goes inactive under some conditions in my iPhone app.

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.