open webform with client script but cant close it

Discussion in 'ASP .Net' started by ton, Feb 21, 2008.

  1. ton

    ton Guest

    Hi,

    I 've a problem. Consider 2 webforms
    webform1 got a button: in the Page_Load event, this code:

    Button1.Attributes.Add("onclick",
    "window.showModalDialog('webform2.aspx',null,'status:no;dialogWidth:370px;dialogHeight:220px;dialogHide:true;help:no;scroll:no');")

    the 2nd form got a button2 in the Page_Load event, this code:

    Button2.Attributes.Add("onclick", "window.close();")

    what happens is that the second dialog is a nice pop-up, but after closing
    it is closed and RELOADED again (but then not as modal form and not in the
    specified height/width

    What am I doing wrong??


    Ton
     
    ton, Feb 21, 2008
    #1
    1. Advertising

  2. Add this line to the <head> section of the page you open as a modal dialog:

    <base target="_self"/>

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "ton" <> wrote in message
    news:b5943$47bd6bff$541eee8e$1.nb.home.nl...
    > Hi,
    >
    > I 've a problem. Consider 2 webforms
    > webform1 got a button: in the Page_Load event, this code:
    >
    > Button1.Attributes.Add("onclick",
    > "window.showModalDialog('webform2.aspx',null,'status:no;dialogWidth:370px;dialogHeight:220px;dialogHide:true;help:no;scroll:no');")
    >
    > the 2nd form got a button2 in the Page_Load event, this code:
    >
    > Button2.Attributes.Add("onclick", "window.close();")
    >
    > what happens is that the second dialog is a nice pop-up, but after closing
    > it is closed and RELOADED again (but then not as modal form and not in the
    > specified height/width
    >
    > What am I doing wrong??
    >
    >
    > Ton
    >
    >
    >
    >
     
    Eliyahu Goldin, Feb 21, 2008
    #2
    1. Advertising

  3. ton

    ton Guest

    WOUW

    it worked great thanks

    Ton

    "Eliyahu Goldin" <> schreef in
    bericht news:...
    > Add this line to the <head> section of the page you open as a modal
    > dialog:
    >
    > <base target="_self"/>
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "ton" <> wrote in message
    > news:b5943$47bd6bff$541eee8e$1.nb.home.nl...
    >> Hi,
    >>
    >> I 've a problem. Consider 2 webforms
    >> webform1 got a button: in the Page_Load event, this code:
    >>
    >> Button1.Attributes.Add("onclick",
    >> "window.showModalDialog('webform2.aspx',null,'status:no;dialogWidth:370px;dialogHeight:220px;dialogHide:true;help:no;scroll:no');")
    >>
    >> the 2nd form got a button2 in the Page_Load event, this code:
    >>
    >> Button2.Attributes.Add("onclick", "window.close();")
    >>
    >> what happens is that the second dialog is a nice pop-up, but after
    >> closing
    >> it is closed and RELOADED again (but then not as modal form and not in
    >> the
    >> specified height/width
    >>
    >> What am I doing wrong??
    >>
    >>
    >> Ton
    >>
    >>
    >>
    >>

    >
    >
     
    ton, Feb 21, 2008
    #3
  4. ton

    bruce barker Guest

    as noted, the webform events are only fired by an async postback. control
    extenders just subscribe to generic browser events (onclick, onfocus, etc),
    so there is no generic tell me when you are done.

    but some extenders will fire events your javascript can subscribe to. the
    auto complete has several events (just look at the javascript code, the best
    documentation). for autocomplete, maybe populated (fired after list is
    loaded) is the event you want, not sure what you are trying to do.

    -- bruce (sqlwork.com)


    "ton" wrote:

    > Hi,
    >
    > I 've a problem. Consider 2 webforms
    > webform1 got a button: in the Page_Load event, this code:
    >
    > Button1.Attributes.Add("onclick",
    > "window.showModalDialog('webform2.aspx',null,'status:no;dialogWidth:370px;dialogHeight:220px;dialogHide:true;help:no;scroll:no');")
    >
    > the 2nd form got a button2 in the Page_Load event, this code:
    >
    > Button2.Attributes.Add("onclick", "window.close();")
    >
    > what happens is that the second dialog is a nice pop-up, but after closing
    > it is closed and RELOADED again (but then not as modal form and not in the
    > specified height/width
    >
    > What am I doing wrong??
    >
    >
    > Ton
    >
    >
    >
    >
    >
     
    bruce barker, Feb 21, 2008
    #4
  5. ton

    siccolo Guest

    On Feb 21, 11:36 am, bruce barker
    <> wrote:
    > as noted, the webform events are only fired by an async postback. control
    > extenders just subscribe to generic browser events (onclick, onfocus, etc),
    > so there is no generic tell me when you are done.
    >
    > but some extenders will fire  events your javascript can subscribe to. the
    > auto complete has several events (just look at the javascript code, the best
    > documentation).  for autocomplete, maybe populated (fired after list is
    > loaded) is the event you want, not sure what you are trying to do.
    >
    > -- bruce (sqlwork.com)
    >
    >
    >
    > "ton" wrote:
    > > Hi,

    >
    > > I 've a problem. Consider 2 webforms
    > > webform1 got a button: in the Page_Load event, this code:

    >
    > > Button1.Attributes.Add("onclick",
    > > "window.showModalDialog('webform2.aspx',null,'status:no;dialogWidth:370px;d­ialogHeight:220px;dialogHide:true;help:no;scroll:no');")

    >
    > > the 2nd form got a button2 in the Page_Load event, this code:

    >
    > > Button2.Attributes.Add("onclick", "window.close();")

    >
    > > what happens is that the second dialog is a nice pop-up, but after closing
    > > it is closed and RELOADED again (but then not as modal form and not in the
    > > specified height/width

    >
    > > What am I doing wrong??

    >
    > > Ton- Hide quoted text -

    >
    > - Show quoted text -


    sometimes, it also helps to show second web form in a iframe....


    ... more at http://www.siccolo.com/articles.asp...
     
    siccolo, Feb 22, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. timmso
    Replies:
    1
    Views:
    496
    Alex Papadimoulis
    Dec 12, 2003
  2. Nagaraj
    Replies:
    1
    Views:
    871
    Lionel B
    Mar 1, 2007
  3. David Laub

    Close a WebForm? SetFocus in a WebForm?

    David Laub, Feb 18, 2004, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    330
    Alvin Bruney [MVP]
    Feb 21, 2004
  4. Iñaki Baz Castillo
    Replies:
    7
    Views:
    868
    Iñaki Baz Castillo
    Jan 12, 2010
  5. Iulian Ilea
    Replies:
    1
    Views:
    318
    pcx99
    Dec 21, 2006
Loading...

Share This Page