473,657 Members | 2,515 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

refresh after event fires

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 is fired, which
is delegated to an ImageButton during runtime. 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");
}
Nov 15 '05 #1
0 1079

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3527
by: hqdtech | last post by:
how to refresh webform from other webform I have 2 webform, i want if webform A was close then webform B wil refresh. And the problem second: how to catch packet on the network in C#. thanks
1
11082
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.
19
3472
by: Heidi Hundåla | last post by:
Hi ! I have a Wep App in C#. Page_Unload fires after Page_Load, and it seems totally unreasonable when you want to use this event when you _leave_ the page. In my project we wanted to use the Page_Unload - event to clean up the Session variables, but when it turns out that it fires before the end, it screws up the code, and
1
3353
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...
0
435
by: ChrisB | last post by:
I'm attempting to open a new window from a LinkButton in a DataGrid. I can set a session variable in the ItemCommand event for the LinkButton like so: // this is used to handle the ItemCommand event private void itmCmd(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { string itemGFNo = ""; if (e.CommandName == "EditTask")
8
1787
by: Paul | last post by:
Hi, In a class i built, i fire an event when a field changes. In a webform that has an instance of the class, the event (from the class) is fired and the code is executed. However, my webpage does not reload (postback) after the event fires. How do i get the webform to postback when the event fires (after the code in the event is done executing)? Thank you, Paul
17
3302
by: Jim Little | last post by:
Hello, I'm driving myself crazy either because I'm missing something about ASP.NET, or what I'm trying to do simply can't be done. First, I am not using session variables to track state. My app will ultimately be web-farmed, so I resisted using either session variables. Second, what I'm trying to do is easy. What I'm trying to prevent seems impossible.
2
1089
by: Fabiano | last post by:
Please, I need refresh automatically my asp.net page into an interval of 30 seconds. But i need that this refresh fires a postback event so i could manage it. Any idea? tks in adv. Fabiano
1
1771
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...
6
1301
by: kirk | last post by:
I have three events, using event handler methods as depicted below. Two of those event handler methods need to reset specific data whenever the other event left fires. I wasn't sure how to properly implement that, is there a better way than using state management variables for each timer as i'm doing in the outline below? private string szProperty1 = null; // updated by class consumer
0
8844
Oralloy
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...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
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, 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...
1
6177
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5643
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();...
0
4173
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...
2
1734
bsmnconsultancy
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...

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.