[
Log In
]
Home
Projects
Professional
Personal
Admin Only
Account Tools
Change Password
About
RSS
All Stories(67)
Mobile(9)
Technology(24)
General(15)
Links(8)
Apps(11)
Firing Event from UserControl to Parent Page
by satman
Ok the site is now back up and running completely recoded in C# from VB.net. It took about a day to convert all the pages and debug all those little issues that made me dislike C# all those years ago.
One Problem I came across was getting a simple Button control in a UserControl to fire an event back to its parent page, after trawling the net and coming across various versions all of which were a little overcomplicated I thought I would post a simple version.
In the UserControl
// eg declare an event called 'fireback' which is an EventHandler
public event EventHandler fireback;
When you want to fire the event back
if (fireback!= null)
//check event is not empty safety
{
fireback(Sender, new EventArgs())
;
//fire event for main page
}
in the Parent Page to consume it , define the connection and the local code to execute on event detection
my_Usercontrol.fireback += new EventHandler(consumerSub)
;
where my_Usercontrol is whatever name you assigned to the UserControl and consumerSub is the code you fire when the event happens, for example
protected void consumerSub(object sender, EventArgs e) { ..code.. }
0 Comments
#86 Friday, December 24, 2010 09:23 PM Filed in Technology
Name
(Required)
Email
(Required)
URI
(will display as a linkback)
Comment
(Required)
86
(no script tags allowed)
Sim Only Con
ElectronicPlumber.com
Raspberry Pi and XBMC
Quiz Service SOAP 1.2
Day 1 withdrawal from World of Warcraft
Val D'Isere Snowboarding 2012
Ipad2 iPhone 4S jailbroken today iOS 5.0.1
Gumtree search tool
LoveFilm 2 Months Free Code
MVC 3 with SQLCE4.0 Roles and Membership
SQL Database Dilemma
Problem with IPAD browser and CSS menu
MetroBank and the Coin Machine
Facebook Changes to How Sharing Works
Google+ Invites Available
Kmeaw 3.55 with BBC Iplayer
Assassins Creed : Brotherhood PS3
Windows MovieMaker and MP4 HD files
[ROM]LeeDrOiD V3.0.6-R2 SMS disappearing Issue
Hide Element until Page Loaded
Comment Spammers
Google FaceTime Video Chat
Alternative to Google AdSense
CMA Alternative Viewer (NSFW)
Google Advert invisible for Default Page
DesiHits
Quote Database
Local Mobile Mast Finder
T-Mobile USA Sold To AT&T
3.60 Version Spoofer v1.1 on Kmeaw 3.55
PS3 Kmeaw 3.55 CFW mod
Wii SoftMod 4.3E
HTC Media Link wireless DLNA
Procrastination
Blog Engine Update IV
Sazneo
www.iSatman.com
New Domain Soon
Next project
Ajax HTML Editor ignores + sign
RSS Feed Update
EasyNews
LeeDroid
MoH vs COD:BO PS3
Corporate Gibberish
boxee.tv HTPC interface
Xenu - great web analyser
Google API protocol 2.0 Atom Feeds
using LINQ to parse XML
Firing Event from UserControl to Parent Page
C# re Write
RSS Feed
John Salomon
Bathroom Presents
Blog Engine Functional
Twitter Post
Blog Compose
Blog Engine Update III
Blog Engine update II
Bugging me today
HTC desire
Blog Engine Update
Contacts Page added
Custom Blog Engine
Google.api Picasa Photos
Blog Engine Updates
Primary Database Test