To call that public method for page validation, place the code in a common class file which is inside of App_Code and then create an object for that class in each page. By that object you can call that pageValidation Method.
For Example :
You have one common class named : CommonClass
inside this commonclass you place the public pageValidation method
Then in side of pageload event of each page just create an object like : CommonClass cmnclass =new CommonClass();
I can't use master page because it requires to change a lot.... i have one top.htm and it is place in each and every page except login page. it contain
Please mark as Answer if post helps[ Imran Khan MCP,SCJP]
I again feel base page as the answer as you can call methods present in a BasePage from a aspx page. But there is no option left other modifying all the pages.
mnuEmployee is only accessible to Code behind file and not the Common Class
Pass it in Parameter
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
luckyforu200...
Participant
1167 Points
434 Posts
Call Code behind method in App_Code folder class
Jul 29, 2009 07:37 AM|LINK
Hi experts,
1 ) Top.htm
<a id = "mnuEmployee" runat ="server" href="#" rel="dropmenu2">Employee |</a>
2) top.htm is included in aspx page
3) Code behind file of aspx
Protected Sub Page_Load event
call PageValidation()
End sub
public function PageValidation()
mnuEmployee.Style.Add("display", "none")
end function
This work fine for 1 page but suppose i have 150 pages then i need to include PageValidation in each and every page.
what i want is placing the PageValidation method in App_Code folder's Common class so that it can be called in each and every page
and event help in editing only single method effect in all.
please help..
bbalavikram
Participant
1068 Points
260 Posts
Re: Call Code behind method in App_Code folder class
Jul 30, 2009 05:19 AM|LINK
Try using a BasePage for your 150 and odd ASPX pages.
Here are some links that may help you master Basepages.
http://www.devexpertise.com/2009/03/25/aspnet-tiptrick-use-a-base-page-class-for-all-application-pages/
http://www.codeproject.com/KB/aspnet/BasePageClass.aspx
http://www.developer.com/net/asp/article.php/3605646
manoranjansa...
Participant
978 Points
226 Posts
Re: Call Code behind method in App_Code folder class
Jul 30, 2009 05:37 AM|LINK
Hi,
To call that public method for page validation, place the code in a common class file which is inside of App_Code and then create an object for that class in each page. By that object you can call that pageValidation Method.
For Example :
You have one common class named : CommonClass
inside this commonclass you place the public pageValidation method
Then in side of pageload event of each page just create an object like : CommonClass cmnclass =new CommonClass();
Then call the pageValidation Method as follows :
cmnclass.pageValidation();
Manoranjan Sahoo
My Site: .Net Articles & Discussion Forum
If My Answer Helps You, Then Please click “Mark as Answer”.
luckyforu200...
Participant
1167 Points
434 Posts
Re: Call Code behind method in App_Code folder class
Jul 30, 2009 07:11 AM|LINK
Yes u r right i can do that but the problem is
mnuEmployee is only accessible to Code behind file and not the Common Class
shahed.kazi
All-Star
17953 Points
3635 Posts
Re: Call Code behind method in App_Code folder class
Jul 30, 2009 07:57 AM|LINK
Instead use masterpage and place the validation code in the masterpage's code behind.
.NET World |Captcha Control
luckyforu200...
Participant
1167 Points
434 Posts
Re: Call Code behind method in App_Code folder class
Jul 30, 2009 08:17 AM|LINK
I can't use master page because it requires to change a lot.... i have one top.htm and it is place in each and every page except login page. it contain
bbalavikram
Participant
1068 Points
260 Posts
Re: Call Code behind method in App_Code folder class
Jul 30, 2009 11:00 AM|LINK
I again feel base page as the answer as you can call methods present in a BasePage from a aspx page. But there is no option left other modifying all the pages.
imran_ku07
All-Star
45785 Points
7698 Posts
MVP
Re: Call Code behind method in App_Code folder class
Jul 30, 2009 12:17 PM|LINK
Pass it in Parameter
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
bbalavikram
Participant
1068 Points
260 Posts
Re: Call Code behind method in App_Code folder class
Jul 30, 2009 12:38 PM|LINK
If mnuEMployee is in the namespace of the website then the class file should know too !!
If not , even then, if you have a BEL layer, then add the name space to the class file.