467,911 Members | 1,499 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,911 developers. It's quick & easy.

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

Nov 19 '05 #1
  • viewed: 8452
Share:
8 Replies
Why ? Telling us the final goal could lead to better suggestions than trying
to fool the ASP.NET infrastructure.

Patrice

--

"Amirallia" <bn**@bluewin.ch> a écrit dans le message de
news:mn***********************@bluewin.ch...
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

Nov 19 '05 #2
If you wish to view the page as it was on the first hit, then a
Response.Redirect(this.ResolveUrl(Request.Url.Abso lutePath)); should do it
for you.

MattC

"Amirallia" <bn**@bluewin.ch> wrote in message
news:mn***********************@bluewin.ch...
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

Nov 19 '05 #3
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.Collections.Specialized.NameValueCollection
DeterminePostBackMode()

{

//return base.DeterminePostBackMode ();

return null;

}

Page.DeterminePostBackMode 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 DeterminePostBackMode() As _
NameValueCollection
[C#]
protected virtual NameValueCollection DeterminePostBackMode();
[C++]
protected: virtual NameValueCollection* DeterminePostBackMode();
[JScript]
protected function DeterminePostBackMode() : NameValueCollection;
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" <bn**@bluewin.ch> wrote in message
news:mn***********************@bluewin.ch...
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

Nov 19 '05 #4
Il se trouve que Patrice a formulé :
Why ? Telling us the final goal could lead to better suggestions than trying
to fool the ASP.NET infrastructure.

Patrice

--

"Amirallia" <bn**@bluewin.ch> a écrit dans le message de
news:mn***********************@bluewin.ch...
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


ok

I fill a datagrid with data and in one column I have a checkbox
(TemplateColumn).
In the DataGrid1_ItemDataBound 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.Text = ""

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

Nov 19 '05 #5
MattC a émis l'idée suivante :
If you wish to view the page as it was on the first hit, then a
Response.Redirect(this.ResolveUrl(Request.Url.Abso lutePath)); should do it
for you.

MattC

"Amirallia" <bn**@bluewin.ch> wrote in message
news:mn***********************@bluewin.ch...
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


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

Nov 19 '05 #6
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" <bn**@bluewin.ch> wrote in message
news:mn***********************@bluewin.ch...
Il se trouve que Patrice a formulé :
Why ? Telling us the final goal could lead to better suggestions than
trying
to fool the ASP.NET infrastructure.

Patrice

--

"Amirallia" <bn**@bluewin.ch> a écrit dans le message de
news:mn***********************@bluewin.ch...
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


ok

I fill a datagrid with data and in one column I have a checkbox
(TemplateColumn).
In the DataGrid1_ItemDataBound 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.Text = ""

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

Nov 19 '05 #7
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" <bn**@bluewin.ch> a écrit dans le message de
news:mn***********************@bluewin.ch...
Il se trouve que Patrice a formulé :
Why ? Telling us the final goal could lead to better suggestions than trying to fool the ASP.NET infrastructure.

Patrice

--

"Amirallia" <bn**@bluewin.ch> a écrit dans le message de
news:mn***********************@bluewin.ch...
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


ok

I fill a datagrid with data and in one column I have a checkbox
(TemplateColumn).
In the DataGrid1_ItemDataBound 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.Text = ""

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

Nov 19 '05 #8
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:
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

Nov 19 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Tom | last post: by
1 post views Thread by Julie Barnet | last post: by
5 posts views Thread by Jeronimo Bertran | last post: by
2 posts views Thread by Byron Hopp [MCS] | last post: by
6 posts views Thread by Shawn | last post: by
2 posts views Thread by DB | last post: by
1 post views Thread by Luqman | last post: by
1 post views Thread by =?Utf-8?B?QnJ5YW4=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.