Results 1 to 9 of 9

Thread: UserControl

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    62

    UserControl

    I have a user control which is linked to the db. It has three buttons: Save, Cancel and Refresh. I wanted to pop up a showmodal window if the user clicks cancel or refresh. I am using C# and javascript. I have added the javascript code for the buttons onclick events. It is not working:
    The showmodal call is like this
    Code:
    window.showModalDialog(webpage,,pagesettings);
    can someone tell me what I am doing wrong? Thanks in advance

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: UserControl

    What are the values of webpage and pagesettings? Try hardcoding all the values and then working your way towards vars from there.

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    62

    Re: UserControl

    webpage is the asp page for the modal window and pagesetting is where the popup window should be and what should be its width, height

  4. #4
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: UserControl

    Is that IE only or does Netscape and so on support the DialogBox type window?
    Magiaus

    If I helped give me some points.

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    62

    Re: UserControl

    It's IE Only.

  6. #6

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    62

    Re: UserControl

    Let me rephrase the question. Can I call onclick event of a button on a aspx page from the usercontrol. Both usercontrol and button is on the same aspx page. Thanks

  7. #7
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: UserControl

    To the best of my knowledge there is no easy way. I had this problem with my cancel button. What I finally did which sucked was to check the URL of the page and take a special action based on the page name. I did things like adding popup to the name of pages that where used in popups and having a special cancel for popups and so on.

    The other answer is to expose the event as an event of the user control and attach an event at the page level. This sucks too because well the point of user controls is ready to go drop in elements....

    What I do to show a popup from a button is to reg a startup script for the page.
    Magiaus

    If I helped give me some points.

  8. #8

    Thread Starter
    Member
    Join Date
    Nov 2004
    Posts
    62

    Re: UserControl

    Can you show me through code of what you mean?
    I guess I am finding out is that you can't use document.getElementById in a user control because it has no idea. Thanks again

  9. #9
    Frenzied Member Magiaus's Avatar
    Join Date
    Mar 2002
    Location
    swamp land
    Posts
    1,267

    Re: UserControl

    The UserControl doesn't have a .ClientID but the controls in the user control do.

    This is from a Cancel Button in one of my UserControls. If the Control is in a PopUp it closes the PopUp otherwise it redirects to another page.

    PHP Code:
            private void Button2_Click(object senderSystem.EventArgs e)
            {
                if(
    Request.Url.AbsoluteUri.ToLower().IndexOf("popup") != -1)
                {
                    
    Page.RegisterStartupScript("-closeMe" this.UniqueID,"<script language=\"JavaScript\"><!--\r\nwindow.close();\r\n\\\\--></script>");
                }
                else
                {
                    
    this.ViewState.Clear();
                    
    Response.Redirect(this.Page.Request.Url.AbsolutePathtrue);
                }
            } 
    In this case I redirect back to the root page because I load My controls on the fly unless they are in a Popup. The default control for most of my pages is a UserControl with a DataGrid used to view the info.
    Magiaus

    If I helped give me some points.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width