Hi, i have a very irriting problem that i have written a short piece of code
to demonstrate. The problem is that my aspx page is not fully refreshed
after an event, which is delegated to an ImageButton during runtime, is
fired. Any suggestions would be great. This code is the c# behind a webform
with 1 panel and 2 buttons on it. I can see that the Page controls are
correct after the event, but the page does not display it this way.
protected System.Web.UI.W ebControls.Butt on Button1;
protected System.Web.UI.W ebControls.Butt on Button2;
protected System.Web.UI.W ebControls.Pane l Panel1;
private void Page_Load(objec t sender, System.EventArg s e)
{
if (Session["table"] != null)
Panel1.Controls .Add((Table) Session["table"]);
else
DisplayTable(tr ue,true);
}
private void DisplayTable(bo ol cell1, bool cell2)
{
Table table = new Table();
Panel1.Controls .Clear();
if (cell1)
{
table.Rows.Add( CreateCell(1));
}
if (cell2)
{
table.Rows.Add( CreateCell(2));
}
Panel1.Controls .Add(table);
Session["table"] = table;
}
private TableRow CreateCell(int cellId)
{
TableRow row = new TableRow();
TableCell cell = new TableCell();
ImageButton button = new ImageButton();
button.Alternat eText = "Button"+cellId ;
button.ID = "BTN"+cellI d;
button.CommandN ame = cellId.ToString ();
EventInfo eventInfo = button.GetType( ).GetEvent("Cli ck");
Delegate d = Delegate.Create Delegate(typeof (ImageClickEven tHandler),
this, "NewPostbackEve nt");
eventInfo.AddEv entHandler(butt on, d);
cell.Controls.A dd(button);
row.Cells.Add(c ell);
return row;
}
private void NewPostbackEven t(object sender,
System.Web.UI.I mageClickEventA rgs e)
{
ImageButton button = (ImageButton) sender;
if (button.Command Name == "1")
DisplayTable(fa lse, true);
else
DisplayTable(tr ue, false);
}
private void Button1_Click(o bject sender, System.EventArg s e)
{
DisplayTable(tr ue,true);
}
private void Button2_Click(o bject sender, System.EventArg s e)
{
// Page.FindContro l("BTN1");
// Page.FindContro l("BTN2");
} 3 2477
"George K" <a@bluefiretech nologies.com> wrote in message
news:ru******** ***********@war ds.force9.net.. . Hi, i have a very irriting problem that i have written a short piece of
code to demonstrate. The problem is that my aspx page is not fully refreshed after an event, which is delegated to an ImageButton during runtime, is fired. Any suggestions would be great. This code is the c# behind a
webform with 1 panel and 2 buttons on it. I can see that the Page controls are correct after the event, but the page does not display it this way.
protected System.Web.UI.W ebControls.Butt on Button1; protected System.Web.UI.W ebControls.Butt on Button2; protected System.Web.UI.W ebControls.Pane l Panel1;
private void Page_Load(objec t sender, System.EventArg s e) { if (Session["table"] != null) Panel1.Controls .Add((Table) Session["table"]); else DisplayTable(tr ue,true); }
I have no idea whether or not this is your problem, but if you put a
reference to the table into Session, and then add it the Controls collection
of the Panel, then table.Parent will point to the Panel control, and
Panel.Parent will point to (for example) the HtmlForm, and form.Parent will
point to the Page.
So, aren't you going to be keeping the entire page around in memory, at
least until the "Panel1.Control s.Add"?
And at that point, I wonder what happens when you take the table out of the
Controls collection of the previous request's Panel1 and put it into the
Panel1 of the current request? Many parts of a Controls lifecycle depend on
which Controls collection the control is in.
--
John Saunders
John.Saunders at SurfControl.com
The reason the table is in a session and put back into the panel controls on
page load is, that if you dont do that, the postback event will not fire at
all because the control is no longer on the page. So you have to put the
control back to allow the postback to fire, then do whatever else you want.
But I think you are right, it is probably a problem with the current
Response object.
"John Saunders" <john.saunder s at SurfControl.com > wrote in message
news:ew******** ******@tk2msftn gp13.phx.gbl... "George K" <a@bluefiretech nologies.com> wrote in message news:ru******** ***********@war ds.force9.net.. . Hi, i have a very irriting problem that i have written a short piece of code to demonstrate. The problem is that my aspx page is not fully refreshed after an event, which is delegated to an ImageButton during runtime, is fired. Any suggestions would be great. This code is the c# behind a webform with 1 panel and 2 buttons on it. I can see that the Page controls are correct after the event, but the page does not display it this way.
protected System.Web.UI.W ebControls.Butt on Button1; protected System.Web.UI.W ebControls.Butt on Button2; protected System.Web.UI.W ebControls.Pane l Panel1;
private void Page_Load(objec t sender, System.EventArg s e) { if (Session["table"] != null) Panel1.Controls .Add((Table) Session["table"]); else DisplayTable(tr ue,true); }
I have no idea whether or not this is your problem, but if you put a reference to the table into Session, and then add it the Controls
collection of the Panel, then table.Parent will point to the Panel control, and Panel.Parent will point to (for example) the HtmlForm, and form.Parent
will point to the Page.
So, aren't you going to be keeping the entire page around in memory, at least until the "Panel1.Control s.Add"?
And at that point, I wonder what happens when you take the table out of
the Controls collection of the previous request's Panel1 and put it into the Panel1 of the current request? Many parts of a Controls lifecycle depend
on which Controls collection the control is in. -- John Saunders John.Saunders at SurfControl.com
"George K" <a@bluefiretech nologies.com> wrote in message
news:ek******** ***********@war ds.force9.net.. . The reason the table is in a session and put back into the panel controls
on page load is, that if you dont do that, the postback event will not fire
at all because the control is no longer on the page. So you have to put the control back to allow the postback to fire, then do whatever else you
want.
The usual solution to this is to recreate the dynamic controls upon
postback. Unless the overhead of creating a specific control is high, I
would think it would be faster to create the controls each time than to keep
them around in Session state.
--
John Saunders
John.Saunders at SurfControl.com This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: George K |
last post by:
Hi, i have a very irriting problem that i have written a short piece of code
to demonstrate. The problem is that my aspx page is not fully refreshed
after an event, which is delegated to an ImageButton during runtime, is
fired. Any suggestions would be great. This code is the c# behind a webform
with 1 panel and 2 buttons on it. I can see that the Page controls are
correct after the event, but the page does not display it this way.
...
|
by: James |
last post by:
I have a data grid refresh problem. I have a few columns and the first
column is data in the form of numbers. And in the form of the data
grid if I specify for example something like a code(in a text box) the
column of numbers should change colors depending on whether the number
was in the specified code(if it belongs to the code, color the cell
(first column) in Red and if not in some other color). It all works
out fine until I scroll...
|
by: Tedb |
last post by:
Is there any reason why you can't reuse a delegate object instance versus
creating a new one each time? For example in the following scenario I have
a DataPoints object with an array of DataPoint objects, each of these has a
Changed event. My Client objects subscribe to some or all of the DataPoint
Changed events. Client1 creates a new delegate instance for each DataPoint
event subscribed to, while Client2 creates one delegate instance...
|
by: Stan |
last post by:
If a page has a button with event handler
private void btnAdd_Click(object sender, System.EventArgs e)
{
.......
}
this event handler fires every time I refresh the page in the browser with
F5 AFTER
the button was clicked.
|
by: ppatel |
last post by:
Problem
I have a problem with web image button control click event. The click event does not get trigger until it has not been clicked once or page refresh occures(which is fine).
When click event fires first time it executes code associate with click event(As I expected). the problem is when you refresh page it fires a click event automatically.
I looked around many posts and did not find any topics about this problem. Infact the same...
| |
by: Kirill Osipov |
last post by:
Hello everybody.
Can anyone help me? I'm writing a server control which raises events. On
MSDN I've read a lot about events and saw a bunch of samples illustrating
the mechanism of events. Among those samples I've saw a couple of ones on
which built-in ASP.NET controls featured event initialization right from
ASCX/ASPX code. For example:
<asp:Repeater id="rptMyRepeater" OnItemDataBound="OnMyRepeaterDataBind"
runat="server">
.......
|
by: JohnJohn |
last post by:
Hello. I have developed a VB.NET 2005 web site using .NET Framework 2.0.
Does anyone know if there is a way for me to detect when a particular page
has been refreshed by means of clicking the refresh button only?
In the brief research I've done, I found the following code:
AddHandler System.ComponentModel.TypeDescriptor.Refreshed, AddressOf
OnRefreshed
I added a corresponding OnRefreshed delegate function. This must not be
what I'm...
|
by: Kevin R |
last post by:
This is one of the weirdest problems I have ever run into. I have had to
trim down a bunch of code to give a sample that is more easily readable by
those who will view this. Here is the problem:
I dynamically add an htmlcheckbox to a webform in the pages render and set
the checked value to true. When the page loads, if I remove the check from
the checkbox and then submit it, in the submit event the checkbox' checked
value is still...
|
by: ffa |
last post by:
In a class called Client I have an event called RefreshData (Public Event
Refresh) which is fired whenever the Client class does a data fetch.
In the main form I declare: Private WithEvents oClient As New Client(dbName)
For some reason the method "oClient_RefreshData() Handles
oClient.RefreshData" no longer fires.
Anyone have any ideas why this is occurring? In fact I have three class
similar to this and they have all stopped firing...
|
by: raylopez99 |
last post by:
Hello all—
I’m trying to get the below to work and cannot get the format right.
It’s from this example: http://msdn.microsoft.com/en-us/library/8627sbea(VS.71).aspx
What it is: I’m trying to store multicast delegates in a hash table,
and then fire the delegates one of two ways (after registering/
creating the delegates, etc).
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |