Refresh GridView from pop-up

Discussion in 'ASP .Net' started by David C, Jul 21, 2009.

  1. David C

    David C Guest

    I have an asp.net web page that contains a GridView showing data from a
    database. I have a LinkButton in one of the GridView columns that has
    OnClientClick = "return opentask();" which opens a pop-up aspx page using
    the following Javascript.

    function opentasks(srecordid) {
    var surl = 'JobTasks.aspx?rid=' + srecordid;
    void window.open(surl, "_blank",
    height=475,width=760,status=yes,toolbar=no,menubar=no,location=no");
    return false;
    }

    What I would like to do is when the JobTasks.aspx (FormView) does an insert
    or update I would like to refresh ( DataBind()? ) the GridView (named
    gvOpenorders) on the calling page.

    Is there an easy way to do this and if so, how? Thanks.

    David
    David C, Jul 21, 2009
    #1
    1. Advertising

  2. David C

    Leon Guest

    On Tue, 21 Jul 2009 10:20:50 -0500, "David C"
    <> wrote:

    >I have an asp.net web page that contains a GridView showing data from a
    >database. I have a LinkButton in one of the GridView columns that has
    >OnClientClick = "return opentask();" which opens a pop-up aspx page using
    >the following Javascript.
    >
    > function opentasks(srecordid) {
    > var surl = 'JobTasks.aspx?rid=' + srecordid;
    > void window.open(surl, "_blank",
    >height=475,width=760,status=yes,toolbar=no,menubar=no,location=no");
    > return false;
    > }
    >
    >What I would like to do is when the JobTasks.aspx (FormView) does an insert
    >or update I would like to refresh ( DataBind()? ) the GridView (named
    >gvOpenorders) on the calling page.
    >
    >Is there an easy way to do this and if so, how? Thanks.
    >
    >David
    >


    Not sure if this would qualify for best answer, but since you are
    using JavaScript windows I'd go for the next approach.

    Add a button or linkbutton to your calling page and attach an event
    handler to it (use dblClick on it) - think you might even be able to
    hide the button; not sure about that though, so better test is visible
    first -
    in that eventhandler refresh the data for the grid. Let's call the
    button RefreshGridButton

    In the JobTasks.aspx you add a JavaScript something like the next:
    <script type="text/javascript">
    <!--
    if (window.opener != null)
    {
    try
    {
    window.opener.javascript:__doPostBack('RefreshGridButton','');
    ---> handle catch

    Think it should work (pretty untested though)

    ..L.
    Leon, Jul 21, 2009
    #2
    1. Advertising

  3. David C

    David C Guest

    "Leon" <> wrote in message
    news:...
    > On Tue, 21 Jul 2009 10:20:50 -0500, "David C"
    > <> wrote:
    >
    >>I have an asp.net web page that contains a GridView showing data from a
    >>database. I have a LinkButton in one of the GridView columns that has
    >>OnClientClick = "return opentask();" which opens a pop-up aspx page using
    >>the following Javascript.
    >>
    >> function opentasks(srecordid) {
    >> var surl = 'JobTasks.aspx?rid=' + srecordid;
    >> void window.open(surl, "_blank",
    >>height=475,width=760,status=yes,toolbar=no,menubar=no,location=no");
    >> return false;
    >> }
    >>
    >>What I would like to do is when the JobTasks.aspx (FormView) does an
    >>insert
    >>or update I would like to refresh ( DataBind()? ) the GridView (named
    >>gvOpenorders) on the calling page.
    >>
    >>Is there an easy way to do this and if so, how? Thanks.
    >>
    >>David
    >>

    >
    > Not sure if this would qualify for best answer, but since you are
    > using JavaScript windows I'd go for the next approach.
    >
    > Add a button or linkbutton to your calling page and attach an event
    > handler to it (use dblClick on it) - think you might even be able to
    > hide the button; not sure about that though, so better test is visible
    > first -
    > in that eventhandler refresh the data for the grid. Let's call the
    > button RefreshGridButton
    >
    > In the JobTasks.aspx you add a JavaScript something like the next:
    > <script type="text/javascript">
    > <!--
    > if (window.opener != null)
    > {
    > try
    > {
    > window.opener.javascript:__doPostBack('RefreshGridButton','');
    > ---> handle catch
    >
    > Think it should work (pretty untested though)
    >
    > .L.


    I will give that a try. I was even thinking of using an AJAX Timer control
    to do a DataBind every xxx seconds that I could activate when I opened the
    new window and then turned it off when I closed it. Not sure how I could
    stop the Timer since it is on the "opener" page. Thanks.

    David
    David C, Jul 21, 2009
    #3
  4. David C

    David C Guest

    Leon,

    It did not like

    window.opener.javascript:__doPostBack('RefreshGridButton','');

    It said 'expected ;' as a page error and it was referencing the colon :))
    you have after the word javascript

    David
    "Leon" <> wrote in message
    news:...
    > On Tue, 21 Jul 2009 10:20:50 -0500, "David C"
    > <> wrote:
    >
    >>I have an asp.net web page that contains a GridView showing data from a
    >>database. I have a LinkButton in one of the GridView columns that has
    >>OnClientClick = "return opentask();" which opens a pop-up aspx page using
    >>the following Javascript.
    >>
    >> function opentasks(srecordid) {
    >> var surl = 'JobTasks.aspx?rid=' + srecordid;
    >> void window.open(surl, "_blank",
    >>height=475,width=760,status=yes,toolbar=no,menubar=no,location=no");
    >> return false;
    >> }
    >>
    >>What I would like to do is when the JobTasks.aspx (FormView) does an
    >>insert
    >>or update I would like to refresh ( DataBind()? ) the GridView (named
    >>gvOpenorders) on the calling page.
    >>
    >>Is there an easy way to do this and if so, how? Thanks.
    >>
    >>David
    >>

    >
    > Not sure if this would qualify for best answer, but since you are
    > using JavaScript windows I'd go for the next approach.
    >
    > Add a button or linkbutton to your calling page and attach an event
    > handler to it (use dblClick on it) - think you might even be able to
    > hide the button; not sure about that though, so better test is visible
    > first -
    > in that eventhandler refresh the data for the grid. Let's call the
    > button RefreshGridButton
    >
    > In the JobTasks.aspx you add a JavaScript something like the next:
    > <script type="text/javascript">
    > <!--
    > if (window.opener != null)
    > {
    > try
    > {
    > window.opener.javascript:__doPostBack('RefreshGridButton','');
    > ---> handle catch
    >
    > Think it should work (pretty untested though)
    >
    > .L.
    David C, Jul 23, 2009
    #4
  5. David C

    Leon Guest

    On Thu, 23 Jul 2009 16:12:31 -0500, "David C"
    <> wrote:

    >Leon,
    >
    >It did not like
    >
    >window.opener.javascript:__doPostBack('RefreshGridButton','');
    >
    >It said 'expected ;' as a page error and it was referencing the colon :))
    >you have after the word javascript
    >
    >David
    >"Leon" <> wrote in message
    >news:...
    >> On Tue, 21 Jul 2009 10:20:50 -0500, "David C"
    >> <> wrote:
    >>
    >>>I have an asp.net web page that contains a GridView showing data from a
    >>>database. I have a LinkButton in one of the GridView columns that has
    >>>OnClientClick = "return opentask();" which opens a pop-up aspx page using
    >>>the following Javascript.
    >>>
    >>> function opentasks(srecordid) {
    >>> var surl = 'JobTasks.aspx?rid=' + srecordid;
    >>> void window.open(surl, "_blank",
    >>>height=475,width=760,status=yes,toolbar=no,menubar=no,location=no");
    >>> return false;
    >>> }
    >>>
    >>>What I would like to do is when the JobTasks.aspx (FormView) does an
    >>>insert
    >>>or update I would like to refresh ( DataBind()? ) the GridView (named
    >>>gvOpenorders) on the calling page.
    >>>
    >>>Is there an easy way to do this and if so, how? Thanks.
    >>>
    >>>David
    >>>

    >>
    >> Not sure if this would qualify for best answer, but since you are
    >> using JavaScript windows I'd go for the next approach.
    >>
    >> Add a button or linkbutton to your calling page and attach an event
    >> handler to it (use dblClick on it) - think you might even be able to
    >> hide the button; not sure about that though, so better test is visible
    >> first -
    >> in that eventhandler refresh the data for the grid. Let's call the
    >> button RefreshGridButton
    >>
    >> In the JobTasks.aspx you add a JavaScript something like the next:
    >> <script type="text/javascript">
    >> <!--
    >> if (window.opener != null)
    >> {
    >> try
    >> {
    >> window.opener.javascript:__doPostBack('RefreshGridButton','');
    >> ---> handle catch
    >>
    >> Think it should work (pretty untested though)
    >>
    >> .L.

    >


    ofcourse it didn't like it..
    it's either:
    function namehere()
    window.opener.__doPostBack('RefreshGridButton','');


    or <a
    href"javascript:window.opener.__doPostBack('RefreshGridButton','');

    but never :javascript inside the function

    the :javascript states: this <a href == is a script call; which
    script??: javascript

    ..L.
    Leon, Jul 24, 2009
    #5
  6. David C

    David C Guest

    "Leon" <> wrote in message
    news:...
    > On Thu, 23 Jul 2009 16:12:31 -0500, "David C"
    > <> wrote:
    >
    >>Leon,
    >>
    >>It did not like
    >>
    >>window.opener.javascript:__doPostBack('RefreshGridButton','');
    >>
    >>It said 'expected ;' as a page error and it was referencing the colon :))
    >>you have after the word javascript
    >>
    >>David
    >>"Leon" <> wrote in message
    >>news:...
    >>> On Tue, 21 Jul 2009 10:20:50 -0500, "David C"
    >>> <> wrote:
    >>>
    >>>>I have an asp.net web page that contains a GridView showing data from a
    >>>>database. I have a LinkButton in one of the GridView columns that has
    >>>>OnClientClick = "return opentask();" which opens a pop-up aspx page
    >>>>using
    >>>>the following Javascript.
    >>>>
    >>>> function opentasks(srecordid) {
    >>>> var surl = 'JobTasks.aspx?rid=' + srecordid;
    >>>> void window.open(surl, "_blank",
    >>>>height=475,width=760,status=yes,toolbar=no,menubar=no,location=no");
    >>>> return false;
    >>>> }
    >>>>
    >>>>What I would like to do is when the JobTasks.aspx (FormView) does an
    >>>>insert
    >>>>or update I would like to refresh ( DataBind()? ) the GridView (named
    >>>>gvOpenorders) on the calling page.
    >>>>
    >>>>Is there an easy way to do this and if so, how? Thanks.
    >>>>
    >>>>David
    >>>>
    >>>
    >>> Not sure if this would qualify for best answer, but since you are
    >>> using JavaScript windows I'd go for the next approach.
    >>>
    >>> Add a button or linkbutton to your calling page and attach an event
    >>> handler to it (use dblClick on it) - think you might even be able to
    >>> hide the button; not sure about that though, so better test is visible
    >>> first -
    >>> in that eventhandler refresh the data for the grid. Let's call the
    >>> button RefreshGridButton
    >>>
    >>> In the JobTasks.aspx you add a JavaScript something like the next:
    >>> <script type="text/javascript">
    >>> <!--
    >>> if (window.opener != null)
    >>> {
    >>> try
    >>> {
    >>> window.opener.javascript:__doPostBack('RefreshGridButton','');
    >>> ---> handle catch
    >>>
    >>> Think it should work (pretty untested though)
    >>>
    >>> .L.

    >>

    >
    > ofcourse it didn't like it..
    > it's either:
    > function namehere()
    > window.opener.__doPostBack('RefreshGridButton','');
    >
    >
    > or <a
    > href"javascript:window.opener.__doPostBack('RefreshGridButton','');
    >
    > but never :javascript inside the function
    >
    > the :javascript states: this <a href == is a script call; which
    > script??: javascript
    >
    > .L.


    Leon,
    I changed it to below, but still no luck, however I am not getting any
    errors. When I click the refresh button on the opener page it does refresh,
    but not when I call it from this pop-up page. Below is my function I have in
    the pop-up page.

    function refreshorders() {
    if (window.opener != null) {
    window.opener.__doPostBack('LBtnRefreshOrders','');
    }
    }


    David
    David C, Jul 25, 2009
    #6
    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. Replies:
    2
    Views:
    8,504
    Randy Webb
    Feb 4, 2006
  2. Bone Ur
    Replies:
    4
    Views:
    372
    Bone Ur
    Dec 19, 2007
  3. Chris Davoli

    Tool Tip pop up - pop up time is too short

    Chris Davoli, Feb 24, 2009, in forum: ASP .Net
    Replies:
    1
    Views:
    453
    Lee Atkinson
    Feb 24, 2009
  4. Pkenty
    Replies:
    0
    Views:
    380
    Pkenty
    May 28, 2004
  5. samppi
    Replies:
    27
    Views:
    454
    David A. Black
    Dec 5, 2007
Loading...

Share This Page