postback to a web custom control Help!!!

Discussion in 'ASP .Net Web Controls' started by Chris, Apr 15, 2004.

  1. Chris

    Chris Guest

    Does anyone know how to postback to an inherited custom control from a
    pop-up window?

    Thanks in advance.
     
    Chris, Apr 15, 2004
    #1
    1. Advertising

  2. How do you mean? The entire form is on the popup window or just a control
    and the main form is on the parent window?

    "Chris" <> wrote in message
    news:...
    > Does anyone know how to postback to an inherited custom control from a
    > pop-up window?
    >
    > Thanks in advance.
    >
    >
     
    Fred Hirschfeld, Apr 15, 2004
    #2
    1. Advertising

  3. Chris

    Chris Guest

    The web control is on the main parent form.
    the control opens a popup window in which has data that I want to post back
    to the server either to the main page web custom control or to an assembly
    on the server.

    Thanks
    "Fred Hirschfeld" <> wrote in message
    news:...
    > How do you mean? The entire form is on the popup window or just a control
    > and the main form is on the parent window?
    >
    > "Chris" <> wrote in message
    > news:...
    > > Does anyone know how to postback to an inherited custom control from a
    > > pop-up window?
    > >
    > > Thanks in advance.
    > >
    > >

    >
    >
     
    Chris, Apr 15, 2004
    #3
  4. So you have a custom control that opens a popup window and does this popup
    window load a page from the server or is it rendered by the custom control?

    Not knowing the exact details, my guess is that you are going to need to
    create some scripting calls (javascript) from the popup window to the
    opening window to repopulate a hidden form element there so the value can be
    posted back. Can you post some specific code so I can provide a better
    answer?

    Fred

    "Chris" <> wrote in message
    news:%...
    > The web control is on the main parent form.
    > the control opens a popup window in which has data that I want to post

    back
    > to the server either to the main page web custom control or to an assembly
    > on the server.
    >
    > Thanks
    > "Fred Hirschfeld" <> wrote in message
    > news:...
    > > How do you mean? The entire form is on the popup window or just a

    control
    > > and the main form is on the parent window?
    > >
    > > "Chris" <> wrote in message
    > > news:...
    > > > Does anyone know how to postback to an inherited custom control from a
    > > > pop-up window?
    > > >
    > > > Thanks in advance.
    > > >
    > > >

    > >
    > >

    >
    >
     
    Fred Hirschfeld, Apr 16, 2004
    #4
  5. Chris

    Chris Guest

    Fred-

    This is the code that produces an aspx,asp or html page to the client this pages data needs to be submitted back to the server to be processed.

    I would prefer to lock the main page as in a modal dialog in windows until the pop-up window is closed and also handle postback either to my control on the main page or another assembly that can be installed on the web server with my control. Any ideas are greatly appreciated.

    Me.Page.Response.Write("<script language='JavaScript'> itemWidth=400; itemHeight=400; w = screen.width; h = screen.height; l=(w-itemWidth)/2; t=(h-itemHeight)/2; void window.open('" & URL & "', '" & sMode & "', 'toolbar=0, directories=0,status=0,menuBar=0,scrollBars=0,resizable=0, width='+itemWidth+', height='+itemHeight+', top='+t+', left='+l)</script>")

    Thanks.

    "Fred Hirschfeld" <> wrote in message news:...
    > So you have a custom control that opens a popup window and does this popup
    > window load a page from the server or is it rendered by the custom control?
    >
    > Not knowing the exact details, my guess is that you are going to need to
    > create some scripting calls (javascript) from the popup window to the
    > opening window to repopulate a hidden form element there so the value can be
    > posted back. Can you post some specific code so I can provide a better
    > answer?
    >
    > Fred
    >
    > "Chris" <> wrote in message
    > news:%...
    > > The web control is on the main parent form.
    > > the control opens a popup window in which has data that I want to post

    > back
    > > to the server either to the main page web custom control or to an assembly
    > > on the server.
    > >
    > > Thanks
    > > "Fred Hirschfeld" <> wrote in message
    > > news:...
    > > > How do you mean? The entire form is on the popup window or just a

    > control
    > > > and the main form is on the parent window?
    > > >
    > > > "Chris" <> wrote in message
    > > > news:...
    > > > > Does anyone know how to postback to an inherited custom control from a
    > > > > pop-up window?
    > > > >
    > > > > Thanks in advance.
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Chris, Apr 16, 2004
    #5
  6. well, you would need to update that script (if not only supporting IE) to do:

    var newWin = window.open(...);
    newWin.opener = window; // make sure the opener property has the parent window

    IE Does have a method to open a dialog but this won't work for netscape... if you only have to deal with IE, then you can use the modal dialog stuff and it will send you a result of your choosing. Then you can place the results in a hidden field of your control or what ever element you have on the parent form.

    So instead of the above, you could use:

    vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])

    where the vArguments can be a single parameter or an array of parameters to pass to the dialog window.

    Calling page:
    <HTML>
    <HEAD>
    <SCRIPT>
    function fnLaunch()
    {
    var aForm;
    aForm = oForm.elements;
    var myObject = new Object();
    myObject.firstName = aForm.oFirstName.value;
    myObject.lastName = aForm.oLastName.value;
    // The object "myObject" is sent to the modal window.
    var retVal = window.showModalDialog("modalDialogSource.htm", myObject, "dialogHeight:300px; dialogLeft:200px;");
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <BUTTON onclick="fnLaunch();" >Launch The Window</BUTTON>
    <FORM ID= "oForm">
    First Name:
    <INPUT TYPE="text" NAME="oFirstName" VALUE="Jane">
    <BR>
    Last Name:
    <INPUT TYPE="text" NAME="oLastName" VALUE="Smith">
    </FORM>
    </BODY>
    </HTML>

    Dialog Page:
    <HTML>
    <HEAD>
    <SCRIPT>
    var oMyObject = window.dialogArguments;
    var sFirstName = oMyObject.firstName;
    var sLastName = oMyObject.lastName;
    </SCRIPT>
    <title>Untitled</title>
    </head>
    <BODY STYLE="font-family: arial; font-size: 14pt; color: Snow;
    background-color: RosyBrown;">

    First Name:
    <SPAN STYLE="color:00ff7f">
    <SCRIPT>
    document.write(sFirstName);
    </SCRIPT>
    </SPAN>
    <BR>
    Last Name:
    <SPAN STYLE="color:00ff7f">
    <SCRIPT>
    document.write(sLastName);
    </SCRIPT>
    </SPAN>
    </BODY>
    </HTML>
    Now your script would use the method window.returnValue [ = vValue ] to return a value (or javascript Object like is shown above) to the parent. This value of object can be accessed through the retVal variable on return of the dialog.Hope this helps, let me know.Fred"Chris" <> wrote in message news:...
    Fred-

    This is the code that produces an aspx,asp or html page to the client this pages data needs to be submitted back to the server to be processed.

    I would prefer to lock the main page as in a modal dialog in windows until the pop-up window is closed and also handle postback either to my control on the main page or another assembly that can be installed on the web server with my control. Any ideas are greatly appreciated.

    Me.Page.Response.Write("<script language='JavaScript'> itemWidth=400; itemHeight=400; w = screen.width; h = screen.height; l=(w-itemWidth)/2; t=(h-itemHeight)/2; void window.open('" & URL & "', '" & sMode & "', 'toolbar=0, directories=0,status=0,menuBar=0,scrollBars=0,resizable=0, width='+itemWidth+', height='+itemHeight+', top='+t+', left='+l)</script>")

    Thanks.

    "Fred Hirschfeld" <> wrote in message news:...
    > So you have a custom control that opens a popup window and does this popup
    > window load a page from the server or is it rendered by the custom control?
    >
    > Not knowing the exact details, my guess is that you are going to need to
    > create some scripting calls (javascript) from the popup window to the
    > opening window to repopulate a hidden form element there so the value can be
    > posted back. Can you post some specific code so I can provide a better
    > answer?
    >
    > Fred
    >
    > "Chris" <> wrote in message
    > news:%...
    > > The web control is on the main parent form.
    > > the control opens a popup window in which has data that I want to post

    > back
    > > to the server either to the main page web custom control or to an assembly
    > > on the server.
    > >
    > > Thanks
    > > "Fred Hirschfeld" <> wrote in message
    > > news:...
    > > > How do you mean? The entire form is on the popup window or just a

    > control
    > > > and the main form is on the parent window?
    > > >
    > > > "Chris" <> wrote in message
    > > > news:...
    > > > > Does anyone know how to postback to an inherited custom control from a
    > > > > pop-up window?
    > > > >
    > > > > Thanks in advance.
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Fred Hirschfeld, Apr 16, 2004
    #6
  7. Chris

    Chris Guest

    The Dialog pop works fine and I can pass data to the popup page but I need to post the result back to the server.

    This page is being generated from a class(Custom Control")
    Therefore how would I ignore other page postbacks and just capture the contents ("textarea") of the poppage and fire dataupdate form the control or a nother componenet.
    "Fred Hirschfeld" <> wrote in message news:...
    well, you would need to update that script (if not only supporting IE) to do:

    var newWin = window.open(...);
    newWin.opener = window; // make sure the opener property has the parent window

    IE Does have a method to open a dialog but this won't work for netscape... if you only have to deal with IE, then you can use the modal dialog stuff and it will send you a result of your choosing. Then you can place the results in a hidden field of your control or what ever element you have on the parent form.

    So instead of the above, you could use:

    vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])

    where the vArguments can be a single parameter or an array of parameters to pass to the dialog window.

    Calling page:
    <HTML>
    <HEAD>
    <SCRIPT>
    function fnLaunch()
    {
    var aForm;
    aForm = oForm.elements;
    var myObject = new Object();
    myObject.firstName = aForm.oFirstName.value;
    myObject.lastName = aForm.oLastName.value;
    // The object "myObject" is sent to the modal window.
    var retVal = window.showModalDialog("modalDialogSource.htm", myObject, "dialogHeight:300px; dialogLeft:200px;");
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <BUTTON onclick="fnLaunch();" >Launch The Window</BUTTON>
    <FORM ID= "oForm">
    First Name:
    <INPUT TYPE="text" NAME="oFirstName" VALUE="Jane">
    <BR>
    Last Name:
    <INPUT TYPE="text" NAME="oLastName" VALUE="Smith">
    </FORM>
    </BODY>
    </HTML>

    Dialog Page:
    <HTML>
    <HEAD>
    <SCRIPT>
    var oMyObject = window.dialogArguments;
    var sFirstName = oMyObject.firstName;
    var sLastName = oMyObject.lastName;
    </SCRIPT>
    <title>Untitled</title>
    </head>
    <BODY STYLE="font-family: arial; font-size: 14pt; color: Snow;
    background-color: RosyBrown;">

    First Name:
    <SPAN STYLE="color:00ff7f">
    <SCRIPT>
    document.write(sFirstName);
    </SCRIPT>
    </SPAN>
    <BR>
    Last Name:
    <SPAN STYLE="color:00ff7f">
    <SCRIPT>
    document.write(sLastName);
    </SCRIPT>
    </SPAN>
    </BODY>
    </HTML>
    Now your script would use the method window.returnValue [ = vValue ] to return a value (or javascript Object like is shown above) to the parent. This value of object can be accessed through the retVal variable on return of the dialog.Hope this helps, let me know.Fred "Chris" <> wrote in message news:...
    Fred-

    This is the code that produces an aspx,asp or html page to the client this pages data needs to be submitted back to the server to be processed.

    I would prefer to lock the main page as in a modal dialog in windows until the pop-up window is closed and also handle postback either to my control on the main page or another assembly that can be installed on the web server with my control. Any ideas are greatly appreciated.

    Me.Page.Response.Write("<script language='JavaScript'> itemWidth=400; itemHeight=400; w = screen.width; h = screen.height; l=(w-itemWidth)/2; t=(h-itemHeight)/2; void window.open('" & URL & "', '" & sMode & "', 'toolbar=0, directories=0,status=0,menuBar=0,scrollBars=0,resizable=0, width='+itemWidth+', height='+itemHeight+', top='+t+', left='+l)</script>")

    Thanks.

    "Fred Hirschfeld" <> wrote in message news:...
    > So you have a custom control that opens a popup window and does this popup
    > window load a page from the server or is it rendered by the custom control?
    >
    > Not knowing the exact details, my guess is that you are going to need to
    > create some scripting calls (javascript) from the popup window to the
    > opening window to repopulate a hidden form element there so the value can be
    > posted back. Can you post some specific code so I can provide a better
    > answer?
    >
    > Fred
    >
    > "Chris" <> wrote in message
    > news:%...
    > > The web control is on the main parent form.
    > > the control opens a popup window in which has data that I want to post

    > back
    > > to the server either to the main page web custom control or to an assembly
    > > on the server.
    > >
    > > Thanks
    > > "Fred Hirschfeld" <> wrote in message
    > > news:...
    > > > How do you mean? The entire form is on the popup window or just a

    > control
    > > > and the main form is on the parent window?
    > > >
    > > > "Chris" <> wrote in message
    > > > news:...
    > > > > Does anyone know how to postback to an inherited custom control from a
    > > > > pop-up window?
    > > > >
    > > > > Thanks in advance.
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Chris, Apr 20, 2004
    #7
  8. Depends on your custom control. I am assuming that you are posting the page back to the server and just want to be able to access the value of the custom control (which would be the return value of the popup). Is this correct?

    I am still not clear how you are intending the post back to happen...

    I would expect that your custom control being used on a page would emit various client side javascript code to popup a dialog window. Then after the user enters the information into this window, they would click a button that would fire a javascript event in the popup page that would set the window.returnValue to whatever the input is expecting. If this is a textarea, then it would set the returnValue to the textarea.value. Then the script would call window.close().

    Once this is done you will have that value returned to you through the vReturnValue variable as shown in the code below. With this you can use the javascript to set a hidden variable on the main pages form to be posted back to the server.

    If you are doing custom rendering, you must ensure the HTML element you create as part of your custom control has the NAME attribute that is the same as the ID of the server control so you get the value posted back properly.

    I am still shooting in the dark unless you can post some code of your control or aspx page. If you would like to e-mail this instead, then send it to fred_hirschfeld at hotmail dot com.

    Fred
    "Chris" <> wrote in message news:...
    The Dialog pop works fine and I can pass data to the popup page but I need to post the result back to the server.

    This page is being generated from a class(Custom Control")
    Therefore how would I ignore other page postbacks and just capture the contents ("textarea") of the poppage and fire dataupdate form the control or a nother componenet.
    "Fred Hirschfeld" <> wrote in message news:...
    well, you would need to update that script (if not only supporting IE) to do:

    var newWin = window.open(...);
    newWin.opener = window; // make sure the opener property has the parent window

    IE Does have a method to open a dialog but this won't work for netscape... if you only have to deal with IE, then you can use the modal dialog stuff and it will send you a result of your choosing. Then you can place the results in a hidden field of your control or what ever element you have on the parent form.

    So instead of the above, you could use:

    vReturnValue = window.showModalDialog(sURL [, vArguments] [, sFeatures])

    where the vArguments can be a single parameter or an array of parameters to pass to the dialog window.

    Calling page:
    <HTML>
    <HEAD>
    <SCRIPT>
    function fnLaunch()
    {
    var aForm;
    aForm = oForm.elements;
    var myObject = new Object();
    myObject.firstName = aForm.oFirstName.value;
    myObject.lastName = aForm.oLastName.value;
    // The object "myObject" is sent to the modal window.
    var retVal = window.showModalDialog("modalDialogSource.htm", myObject, "dialogHeight:300px; dialogLeft:200px;");
    }
    </SCRIPT>
    </HEAD>
    <BODY>
    <BUTTON onclick="fnLaunch();" >Launch The Window</BUTTON>
    <FORM ID= "oForm">
    First Name:
    <INPUT TYPE="text" NAME="oFirstName" VALUE="Jane">
    <BR>
    Last Name:
    <INPUT TYPE="text" NAME="oLastName" VALUE="Smith">
    </FORM>
    </BODY>
    </HTML>

    Dialog Page:
    <HTML>
    <HEAD>
    <SCRIPT>
    var oMyObject = window.dialogArguments;
    var sFirstName = oMyObject.firstName;
    var sLastName = oMyObject.lastName;
    </SCRIPT>
    <title>Untitled</title>
    </head>
    <BODY STYLE="font-family: arial; font-size: 14pt; color: Snow;
    background-color: RosyBrown;">

    First Name:
    <SPAN STYLE="color:00ff7f">
    <SCRIPT>
    document.write(sFirstName);
    </SCRIPT>
    </SPAN>
    <BR>
    Last Name:
    <SPAN STYLE="color:00ff7f">
    <SCRIPT>
    document.write(sLastName);
    </SCRIPT>
    </SPAN>
    </BODY>
    </HTML>
    Now your script would use the method window.returnValue [ = vValue ] to return a value (or javascript Object like is shown above) to the parent. This value of object can be accessed through the retVal variable on return of the dialog.Hope this helps, let me know.Fred "Chris" <> wrote in message news:...
    Fred-

    This is the code that produces an aspx,asp or html page to the client this pages data needs to be submitted back to the server to be processed.

    I would prefer to lock the main page as in a modal dialog in windows until the pop-up window is closed and also handle postback either to my control on the main page or another assembly that can be installed on the web server with my control. Any ideas are greatly appreciated.

    Me.Page.Response.Write("<script language='JavaScript'> itemWidth=400; itemHeight=400; w = screen.width; h = screen.height; l=(w-itemWidth)/2; t=(h-itemHeight)/2; void window.open('" & URL & "', '" & sMode & "', 'toolbar=0, directories=0,status=0,menuBar=0,scrollBars=0,resizable=0, width='+itemWidth+', height='+itemHeight+', top='+t+', left='+l)</script>")

    Thanks.

    "Fred Hirschfeld" <> wrote in message news:...
    > So you have a custom control that opens a popup window and does this popup
    > window load a page from the server or is it rendered by the custom control?
    >
    > Not knowing the exact details, my guess is that you are going to need to
    > create some scripting calls (javascript) from the popup window to the
    > opening window to repopulate a hidden form element there so the value can be
    > posted back. Can you post some specific code so I can provide a better
    > answer?
    >
    > Fred
    >
    > "Chris" <> wrote in message
    > news:%...
    > > The web control is on the main parent form.
    > > the control opens a popup window in which has data that I want to post

    > back
    > > to the server either to the main page web custom control or to an assembly
    > > on the server.
    > >
    > > Thanks
    > > "Fred Hirschfeld" <> wrote in message
    > > news:...
    > > > How do you mean? The entire form is on the popup window or just a

    > control
    > > > and the main form is on the parent window?
    > > >
    > > > "Chris" <> wrote in message
    > > > news:...
    > > > > Does anyone know how to postback to an inherited custom control from a
    > > > > pop-up window?
    > > > >
    > > > > Thanks in advance.
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    Fred Hirschfeld, Apr 21, 2004
    #8
    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. Stan Sainte-Rose

    PostBack Within web custom control

    Stan Sainte-Rose, Sep 7, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    348
    Stan Sainte-Rose
    Sep 7, 2004
  2. gnewsgroup
    Replies:
    1
    Views:
    401
    gnewsgroup
    Feb 13, 2008
  3. Matt Sokol
    Replies:
    2
    Views:
    437
    Theo Tillotson
    Aug 7, 2003
  4. Chris

    Postback to a web custom control HELP Please!!!

    Chris, Apr 15, 2004, in forum: ASP .Net Building Controls
    Replies:
    3
    Views:
    126
    Fred Hirschfeld
    Apr 16, 2004
  5. Leyla

    Web user control - custom web control - java script.

    Leyla, May 1, 2006, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    138
    Leyla
    May 1, 2006
Loading...

Share This Page