473,405 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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
8 9079
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tom | last post by:
Does anyone know how ot force a postback in the codebehind? Thanks Tom
1
by: Julie Barnet | last post by:
I would like to be able to force a postback when a user tabs off of a user control. I currently have the following code: <script language="JavaScript1.1"><!-- function keyPressed() {...
1
by: Andreas Klemt | last post by:
Hello, when SmartNavigation is True how can I force after Postback that the page goes to the top because of the error message or where should I put the error message (top or button)? With old...
3
by: aaa | last post by:
I am checking if a certain object is null and if it is I need to go back to ther server and get this object can I force a postback in the code behind and if so how?
5
by: Jeronimo Bertran | last post by:
I have a DataGrid that gets filled based on a filter which is defined by the values that the user selects on several controls. When the page postbacks after changing the selection on the filter...
2
by: Byron Hopp [MCS] | last post by:
How do you force a postback, we have a button to save our users entry, but the button does not have a postback property (like the dropdownlistbox). Is there a way to force a postback? Byron...
6
by: Shawn | last post by:
Any ideas how I can have a button click on one open page force a postback on a different page.
2
by: DB | last post by:
I have a page that uses ComponentArt components. I have an imagebutton to update one part of the page and there is a graph that should update with it. The problem is the graph has some funky...
1
by: Luqman | last post by:
I have created a page1.aspx with a button, when I click on button, page2.aspx is opened on top of page1.aspx as a New Popup Window using Javascript Window.Open. Now, when I select the data on...
1
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Is there a way to force a "traditional" full page postback in AJAX? I have a page with multiple UpdatePanels and I usually call UpdatePanel.Update() to do a partial postback, but I have one...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.