Force PostBack

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Amirallia

    Force PostBack

    Hello

    I want to force the Page.IsPostBack to false when I click an
    "asp:button "

    Is it possible ?

    --
    Ceci est une signature automatique de MesNews.
    Site : http://www.mesnews.net

  • Patrice

    #2
    Re: Force PostBack

    Why ? Telling us the final goal could lead to better suggestions than trying
    to fool the ASP.NET infrastructure.

    Patrice

    --

    "Amirallia" <bnob@bluewin.c h> a écrit dans le message de
    news:mn.83757d5 25fc91f39.21287 @bluewin.ch...[color=blue]
    > Hello
    >
    > I want to force the Page.IsPostBack to false when I click an
    > "asp:button "
    >
    > Is it possible ?
    >
    > --
    > Ceci est une signature automatique de MesNews.
    > Site : http://www.mesnews.net
    >[/color]


    Comment

    • MattC

      #3
      Re: Force PostBack

      If you wish to view the page as it was on the first hit, then a
      Response.Redire ct(this.Resolve Url(Request.Url .AbsolutePath)) ; should do it
      for you.

      MattC

      "Amirallia" <bnob@bluewin.c h> wrote in message
      news:mn.83757d5 25fc91f39.21287 @bluewin.ch...[color=blue]
      > Hello
      >
      > I want to force the Page.IsPostBack to false when I click an "asp:button "
      >
      > Is it possible ?
      >
      > --
      > Ceci est une signature automatique de MesNews.
      > Site : http://www.mesnews.net
      >[/color]


      Comment

      • Prodip Saha

        #4
        Re: Force PostBack

        I don't know why you want to do that but here is how you can override a
        method (of the Page class) that will set the IsPostback to false-

        protected override System.Collecti ons.Specialized .NameValueColle ction
        DeterminePostBa ckMode()

        {

        //return base.DetermineP ostBackMode ();

        return null;

        }

        Page.DetermineP ostBackMode Method [C#]
        See Also
        Page Class | Page Members | System.Web.UI Namespace | HttpContext | Page
        Members (Visual J# Syntax) | Managed Extensions for C++ Programming

        Requirements
        Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

        Language
        a.. C#

        b.. C++

        c.. JScript

        d.. Visual Basic

        e.. Show All
        Determines the type of request made for the Page class.

        [Visual Basic]
        Protected Overridable Function DeterminePostBa ckMode() As _
        NameValueCollec tion
        [C#]
        protected virtual NameValueCollec tion DeterminePostBa ckMode();
        [C++]
        protected: virtual NameValueCollec tion* DeterminePostBa ckMode();
        [JScript]
        protected function DeterminePostBa ckMode() : NameValueCollec tion;
        Return Value
        If the post back used the POST method, the form information is returned from
        the Context object. If the postback used the GET method, the query string
        information is returned. If the page is being requested for the first time,
        a null reference (Nothing in Visual Basic) is returned.

        Remarks
        This information is based on whether the page was posted back and whether
        the GET or POST HTTP method was used for the request.


        "Amirallia" <bnob@bluewin.c h> wrote in message
        news:mn.83757d5 25fc91f39.21287 @bluewin.ch...[color=blue]
        > Hello
        >
        > I want to force the Page.IsPostBack to false when I click an
        > "asp:button "
        >
        > Is it possible ?
        >
        > --
        > Ceci est une signature automatique de MesNews.
        > Site : http://www.mesnews.net
        >[/color]


        Comment

        • Amirallia

          #5
          Re: Force PostBack

          Il se trouve que Patrice a formulé :[color=blue]
          > Why ? Telling us the final goal could lead to better suggestions than trying
          > to fool the ASP.NET infrastructure.
          >
          > Patrice
          >
          > --
          >
          > "Amirallia" <bnob@bluewin.c h> a écrit dans le message de
          > news:mn.83757d5 25fc91f39.21287 @bluewin.ch...[color=green]
          >> Hello
          >>
          >> I want to force the Page.IsPostBack to false when I click an
          >> "asp:button "
          >>
          >> Is it possible ?
          >>
          >> --
          >> Ceci est une signature automatique de MesNews.
          >> Site : http://www.mesnews.net[/color][/color]

          ok

          I fill a datagrid with data and in one column I have a checkbox
          (TemplateColumn ).
          In the DataGrid1_ItemD ataBound event, I set the checkbox visible or not
          depending of some conditions.

          In this same page I have a button to clear a textbox : here is the code
          on the button_click :Me.TextBox1.Te xt = ""

          When I click on this button, the textbox is cleared and my datagrid
          shows all the checkbox in the column, so it doesn't execute the
          ItemDataBound event.

          I write this in the page_load event :
          If Not Page.IsPostBack Then
          .........
          fill my datagrid
          end if

          When I click on my button, the Page.IsPostBack is true so I don't fill
          my datagrid and not event ItemDataBound fired

          --
          Ceci est une signature automatique de MesNews.
          Site : http://www.mesnews.net

          Comment

          • Amirallia

            #6
            Re: Force PostBack

            MattC a émis l'idée suivante :[color=blue]
            > If you wish to view the page as it was on the first hit, then a
            > Response.Redire ct(this.Resolve Url(Request.Url .AbsolutePath)) ; should do it
            > for you.
            >
            > MattC
            >
            > "Amirallia" <bnob@bluewin.c h> wrote in message
            > news:mn.83757d5 25fc91f39.21287 @bluewin.ch...[color=green]
            >> Hello
            >>
            >> I want to force the Page.IsPostBack to false when I click an "asp:button "
            >>
            >> Is it possible ?
            >>
            >> -- Ceci est une signature automatique de MesNews.
            >> Site : http://www.mesnews.net
            >>[/color][/color]

            Your solution is ok fro all the page, but I only want to fix a colum in
            a datagrid, not all the page

            Any another idea ?

            --
            Ceci est une signature automatique de MesNews.
            Site : http://www.mesnews.net

            Comment

            • MattC

              #7
              Re: Force PostBack

              The ItemDataBound event will not fire as the grid is not having new data
              added to it, it is simply having its viewstate repopulated. To get your
              event to fire each time around you would need to bind the grid each time.
              Move it out of the
              If Not Page.IsPostBack block.

              MattC
              "Amirallia" <bnob@bluewin.c h> wrote in message
              news:mn.83a87d5 2aa776c01.21287 @bluewin.ch...[color=blue]
              > Il se trouve que Patrice a formulé :[color=green]
              >> Why ? Telling us the final goal could lead to better suggestions than
              >> trying
              >> to fool the ASP.NET infrastructure.
              >>
              >> Patrice
              >>
              >> --
              >>
              >> "Amirallia" <bnob@bluewin.c h> a écrit dans le message de
              >> news:mn.83757d5 25fc91f39.21287 @bluewin.ch...[color=darkred]
              >>> Hello
              >>>
              >>> I want to force the Page.IsPostBack to false when I click an
              >>> "asp:button "
              >>>
              >>> Is it possible ?
              >>>
              >>> --
              >>> Ceci est une signature automatique de MesNews.
              >>> Site : http://www.mesnews.net[/color][/color]
              >
              > ok
              >
              > I fill a datagrid with data and in one column I have a checkbox
              > (TemplateColumn ).
              > In the DataGrid1_ItemD ataBound event, I set the checkbox visible or not
              > depending of some conditions.
              >
              > In this same page I have a button to clear a textbox : here is the code on
              > the button_click :Me.TextBox1.Te xt = ""
              >
              > When I click on this button, the textbox is cleared and my datagrid shows
              > all the checkbox in the column, so it doesn't execute the ItemDataBound
              > event.
              >
              > I write this in the page_load event :
              > If Not Page.IsPostBack Then
              > ........
              > fill my datagrid
              > end if
              >
              > When I click on my button, the Page.IsPostBack is true so I don't fill my
              > datagrid and not event ItemDataBound fired
              >
              > --
              > Ceci est une signature automatique de MesNews.
              > Site : http://www.mesnews.net
              >[/color]


              Comment

              • Patrice

                #8
                Re: Force PostBack

                Possible options would be :
                - if you want to rebind on postback just suppress the test ?????!!! instead
                of fooling ASP.NET ???
                - you could also have the checkbox computation outside of this event. It
                would allow to recompute the textobx wihtout binding the grid again
                - you could also add a new column in your datasource to achieve the same
                result...

                Patrice

                --

                "Amirallia" <bnob@bluewin.c h> a écrit dans le message de
                news:mn.83a87d5 2aa776c01.21287 @bluewin.ch...[color=blue]
                > Il se trouve que Patrice a formulé :[color=green]
                > > Why ? Telling us the final goal could lead to better suggestions than[/color][/color]
                trying[color=blue][color=green]
                > > to fool the ASP.NET infrastructure.
                > >
                > > Patrice
                > >
                > > --
                > >
                > > "Amirallia" <bnob@bluewin.c h> a écrit dans le message de
                > > news:mn.83757d5 25fc91f39.21287 @bluewin.ch...[color=darkred]
                > >> Hello
                > >>
                > >> I want to force the Page.IsPostBack to false when I click an
                > >> "asp:button "
                > >>
                > >> Is it possible ?
                > >>
                > >> --
                > >> Ceci est une signature automatique de MesNews.
                > >> Site : http://www.mesnews.net[/color][/color]
                >
                > ok
                >
                > I fill a datagrid with data and in one column I have a checkbox
                > (TemplateColumn ).
                > In the DataGrid1_ItemD ataBound event, I set the checkbox visible or not
                > depending of some conditions.
                >
                > In this same page I have a button to clear a textbox : here is the code
                > on the button_click :Me.TextBox1.Te xt = ""
                >
                > When I click on this button, the textbox is cleared and my datagrid
                > shows all the checkbox in the column, so it doesn't execute the
                > ItemDataBound event.
                >
                > I write this in the page_load event :
                > If Not Page.IsPostBack Then
                > ........
                > fill my datagrid
                > end if
                >
                > When I click on my button, the Page.IsPostBack is true so I don't fill
                > my datagrid and not event ItemDataBound fired
                >
                > --
                > Ceci est une signature automatique de MesNews.
                > Site : http://www.mesnews.net
                >[/color]


                Comment

                • Bill Borg

                  #9
                  RE: Force PostBack

                  One time I wanted to modify the value of page.ispostback , but some people out
                  here rightly convinced me it was a horrible idea due to lack of understanding
                  of asp.net.

                  I'm not sure I understand your requirements, but you might also consider
                  ItemCreated. ItemCreated fires *every* time each row in the datagrid is
                  created, whether via databinding or restore from viewstate after postback,
                  whereas ItemDataBound is only fired when you explicitly call .databind.

                  Bill

                  "Amirallia" wrote:
                  [color=blue]
                  > Hello
                  >
                  > I want to force the Page.IsPostBack to false when I click an
                  > "asp:button "
                  >
                  > Is it possible ?
                  >
                  > --
                  > Ceci est une signature automatique de MesNews.
                  > Site : http://www.mesnews.net
                  >
                  >[/color]

                  Comment

                  Working...