![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| [SOLVED] Help with Master Page / Content Page in ASP.NET? I designed a Master Page with three link buttons in it: lnk1, lnk2 and lnk3. I have also designed a content page that inherits from the Master Page (I just added an extra property on the topmost line of the Content-Page's Source that says " MasterPageFile="~/MP1.master" ") I would like to add new events (i.e. override them) for the above three links in my Content Page. By default, those links do nothing - what should I do to override the links and add new events that occur by clicking on them? The programming language involved here is C#, therefore no VB coding please. |
| |
| |||
| I think you can do a trick to produce the same result. I am not sure if the "overriding the events" itself is possible. However what I imaging is possible is to leave your controls in the Master Page unwired. In the content page's Page_Init method, reference the control in your master page and wire its event. For example: protected void Page_Init(object sender, EventArgs e) { ( ( LinkButton )Master.FindControl( "MyLinkBtn" ) ).Click += new EventHandler( this.MyLinkBtn_Click); } Hope this helps. |
| |||
| I think there would be someway to do that although it might seem messy. It's fortunate that your event handler in the master page does not do anything originally, so you needn't check some flag in the event args to verify whether you should cancel the original behavior or not. consider using a public dummy class which fires events in the master page. In the content page add a handler for that. make the object in the master page public so that your content page can see it by casting. Good luck. |
![]() |
| Thread Tools | |
| Display Modes | |
| |