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 264117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:39:31+00:00 2026-05-11T22:39:31+00:00

I use an ajax ModalPopupExtender on many pages to display confirmation dialog. So i

  • 0

I use an ajax ModalPopupExtender on many pages to display confirmation dialog.

So i would like to reuse same code on all pages by placing it in a use control.
But I’m not sure it it possible to access this user control from a javascript (I don’t want server side operations).

This is the code that is responsible for popup display, that i want to place inside user control:

<script language="javascript" type="text/javascript">
    var _source;
    var _popup;
    var _btn;
    var _div;

    function showConfirm(source, btnID, theDiv) {

        this._source = source;
        this._btn = btnID;
        this._div = theDiv;

        document.getElementById(btnID).click();   
        document.getElementById(theDiv).style.visibility = 'visible';
    }

        function okClick() {

            document.getElementById(_div).style.visibility = 'hidden';
            __doPostBack(this._source.name, '');
        }

        function cancelClick() {
            document.getElementById(_div).style.visibility = 'hidden';
            this._source = null;
        }
    </script>


 <cc1:ModalPopupExtender ID="modal" runat="server"
        TargetControlID="theButton" PopupControlID="div"
        OkControlID="btnOk" OnOkScript="okClick();" CancelControlID="btnNo"
        OnCancelScript="cancelClick();" BackgroundCssClass="modalBackground" />

 <div id="div" runat="server" align="center" class="confirm" style="display: none">
    <img align="absmiddle" src="../images/warning.jpg" />Are you sure you want to delete this item?
    </br>
    <asp:Button ID="btnOk" runat="server" Text="Yes" Width="50px" />
    <asp:Button ID="btnNo" runat="server" Text="No" Width="50px" />
 </div>

And on the “hosting” page, I want to assign JS to a buttons that will trigger the popup:
This is the code that i have now (and should be adopted to the user control):

string s = string.Format("showConfirm(this,'{0}','{1}');return false;", theButton.ClientID, div.ClientID);            
btn.OnClientClick = s;
  • 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-05-11T22:39:31+00:00Added an answer on May 11, 2026 at 10:39 pm

    It’s possible to call the modal popup extender from javascript as the modal popup control is just another DOM element. All you need to know is a selector which can select the item.

    To “show” your modal popup extender from javascript all you will need to do is add some script to your master-page, user-control or page which displays the dom element which is the modal popup extender.

    Alternatively you can use a javascript framework which has many other styles of modal dialog which are equally (if not more) useful than the ajax modal popup extender. This is probably more relevant to what you are trying to achieve considering your don’t want to use ASP.NET’s server side code capabilities.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have many forms that use AJAX (w/ jQuery) for validation and data submission.
I'm trying to use Ajax Toolkit in ASP.NET page to display a Calendar Extender
I am trying to use ajax to load sometag , but my appended code
I want use ajax.net to do some js. like below: ScriptManager.RegisterStartupScript(Submit, typeof(Button), alert, location.href='test.aspx';,
I am trying to use Ajax to allow a user to save information (display
I am trying to use AJAX UpdateProgress to display the loading image when the
Many sites nowadays use AJAX to let users login. However there is a (I
I don't currently use ajax.net though I would be open to it if it
How would I use Ajax do a filtering on a list view in MVC.
I use ajax to run MySQL query and echo json_encode result, so that I

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.