Handeling Control Events from Web Form page

I am working with an existing C#.net project. I have created a control of radio buttons in a new .ascx page. I am placing that .ascx control on multiple pages throughout the site where the functionality is needed. The control is replacing existing radio buttons on various pages where there is code written for it. One of the pages that I have come across has some events tied to the radio buttons, that I cannot include in the new generic control, as it would not apply to all other areas.

With that all said... after placing the control on the page, is there a way to have the main form handle a selectindexchanged event from the control without that event firing when placing that control on other pages?
LVL 4
Michael KrumpeSolutions ArchitectAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rog DManager Inforamtion SystemsCommented:
0
Rog DManager Inforamtion SystemsCommented:
This link maybe more informative

http://www.15seconds.com/issue/020319.htm

As the one above seems to be more on Gridview events.

Rog
0
Michael KrumpeSolutions ArchitectAuthor Commented:
I understand how to make a control,... the control is already made and functioning. I need to make a specific page that I put the control on to respond to one of the controls events in its own way.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Rog DManager Inforamtion SystemsCommented:
My fault, those articles only talked about user controls, I thought they also included event handling.


Here they discuss events...
http://www.eggheadcafe.com/articles/20050710.asp

Look at Adding Events: section in the middle of the page.

0
Rog DManager Inforamtion SystemsCommented:
Here is a real rough idea of what we do.. .. I just could not find it on the web....

This is not compiled code it is just a snipet from a parent and user control.

We use http://www.denisbauer.com/Default.aspx dynamiccontrolplaceholder control for our controls, but it is just a placeholder that allows some better handeling of events and viewstate on the controls on postback.

Anyway take a look at the code and hopefully the sample and the links above will help you out.

Rog
In the parent control
 
 
Page_Init sub
	AddHandler usercontrol.Item_saved, AddressOf listen_Item_saved
end sub
 
 
 
Private Sub listen_Item_Saved()
        Session("Item" & win_id) = Nothing
end Sub
 
End class
 
 
 
 
 
In the child control....
 
 
Partial Public Class userControl1
 
	Inherits userControl
 
	Public Event Item_Saved()
 
 
Private Sub btn_save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn_save.Click
        ' save the college to the database and raise an event for the page to respond to.
        If Page.IsValid Then
            Try
                RaiseEvent Item_saved()
            Catch ex As Exception
		throw ex
            End Try
        End If
    End Sub
 
 
end class

Open in new window

0
Michael KrumpeSolutions ArchitectAuthor Commented:
In this instance, do you create a delegate for the Event Handler?
0
Rog DManager Inforamtion SystemsCommented:
No delegate needed.

I think the Public Event is like the delegate.  I am not sure as I have not used Delegates.

The above works though.

Give it a try with your control.

Rog
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rog DManager Inforamtion SystemsCommented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.