| | |
Execute MastePage event from a content webform
Please support our ASP.NET advertiser: Intel Parallel Studio Home
Thread Solved |
Hi, I would like to know how can I execute an event from a web content form, for example i would like to run a centralized event to assign rigths to component in every webform, but i would like to do that from the master page so i do not have to redo the same code in all web form load event.
Thanks for any help you can provide me. VS2008
Thanks for any help you can provide me. VS2008
If your already resolved your issue, flag it as solved.
José Bisonó
José Bisonó
•
•
Join Date: Jun 2009
Posts: 439
Reputation:
Solved Threads: 82
0
#2 Oct 26th, 2009
Each child web forms will have different controls. If you want to access child page controls in your master page, then you can do it something like
Or do you want to get master page event in your child pages? if so, refer this link.
ASP.NET Syntax (Toggle Plain Text)
ContentPlaceHolder1.FindControl("Button1")
Or do you want to get master page event in your child pages? if so, refer this link.
Last edited by Ramesh S; Oct 26th, 2009 at 3:43 am.
0
#3 Oct 26th, 2009
Actually is something like the link you provide here, but i do not have any button to trigger this code it just run in the load page, well the thing is that piece of code is general for every single webform i have, but then maybe i would like to add some code to the specific webform. I hope you know what im saying.
If your already resolved your issue, flag it as solved.
José Bisonó
José Bisonó
•
•
Join Date: Jun 2009
Posts: 439
Reputation:
Solved Threads: 82
0
#4 Oct 26th, 2009
Hi jbisono ,
I am clear about your requirement now. You may need to write code specific to the child pages in the page _load event of the master page. So that it will be executed automatically for all child pages.
You can use Page.GetType().Name or other technique like this to get the child page name in Master page and write the specifc code to it.
Alternatively you can create BasePage class and inherit all your child pages from this class.Override the OnLoad event in the BasePage and write code specific to the pages inherited from it.
I am clear about your requirement now. You may need to write code specific to the child pages in the page _load event of the master page. So that it will be executed automatically for all child pages.
You can use Page.GetType().Name or other technique like this to get the child page name in Master page and write the specifc code to it.
Alternatively you can create BasePage class and inherit all your child pages from this class.Override the OnLoad event in the BasePage and write code specific to the pages inherited from it.
Last edited by Ramesh S; Oct 26th, 2009 at 9:49 am.
0
#5 Oct 26th, 2009
Ok, Thanks Ramesh, Actually with your previous comment i got it to do what i want, but the master page load event trigger after the content load event which i would like to run the content load event after the master page. if that possible?.
If your already resolved your issue, flag it as solved.
José Bisonó
José Bisonó
0
#6 Oct 26th, 2009
Ok, Ramesh I think i got it, I use the link you provide to use the preinit but insted of using preinit i use prerender in that case i can execute my code from the master page in the load event in then the prerender in the content page to whatever i want in my content form. what do you think is that a good practice?.
Oh and thank you for your help.
Oh and thank you for your help.
If your already resolved your issue, flag it as solved.
José Bisonó
José Bisonó
•
•
Join Date: Jun 2009
Posts: 439
Reputation:
Solved Threads: 82
1
#7 Oct 27th, 2009
Hi jbisono,
The values of the controls will not be loaded from ViewState in PreInit event. Therefore avoid to use it.
Since it seems that you want to execute some code in master page and then some code in child pages, what you mentioned is a good idea.
The values of the controls will not be loaded from ViewState in PreInit event. Therefore avoid to use it.
Since it seems that you want to execute some code in master page and then some code in child pages, what you mentioned is a good idea.
Last edited by Ramesh S; Oct 27th, 2009 at 2:01 am.
![]() |
Similar Threads
- tool strip button (VB.NET)
- Execute PHP file in the background from html page (PHP)
- Java Chat "Help" (Java)
- Account Unknown in permissions (Windows NT / 2000 / XP)
- Overriding the functionality of the controls of the masterpage in the content pages (ASP.NET)
- enable LinkButton from another page (ASP.NET)
- help me.. (C++)
- Transfering javascript on content page (ASP.NET)
- Applet and i/o (Java)
- improve events speed (C#)
Other Threads in the ASP.NET Forum
- Previous Thread: How to maintain scroll position.
- Next Thread: Need to be able to move rows in GridView or something similar
| Thread Tools | Search this Thread |
.net activexcontrol advice ajax alltypeofvideos appliances asp asp.net bc30451 beginner bottomasp.net box browser button c# cac checkbox click commonfunctions control css dataaccesslayer database datagridview datagridviewcheckbox datalist deployment development dgv dialog dropdownlist dynamic dynamically edit embeddingactivexcontrol expose fileuploader fill findcontrol flash form formatdecimal formview gridview gudi iframe iis javascript listbox login microsoft mono mouse mssql multistepregistration news novell numerical opera panelmasterpagebuttoncontrols parent radio redirect registration relationaldatabases reportemail rotatepage save schoolproject search security sessionvariables silverlight smartcard smoobjects software sql-server sqlserver2005 ssl suse textbox tracking treeview unauthorized validatedate validation vb.net video videos virtualdirectory vista visualstudio web webapplications webdevelopemnt webdevelopment webprogramming webservice xsl youareanotmemberofthedebuggerusers





