Click here to Skip to main content
15,915,801 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
I have multiple pages. Each page is have different layout. I have to do common coding to assign data to controls from page layout. Data is different & layout is different. Currently i am setting data in each page load event. I want some common functionality. What can be done?

Thanks
Posted
Updated 4-Jun-12 20:16pm
v2

you can use param parameter to do so

example

C#
public void SetData (string data,params object[] Control)
{
if (Control.GetType() == typeof(TextBox))
 ((TextBox)Control).Text=data;
//-- like that you can add data to different type of controls
}
 
Share this answer
 
Comments
Prasad_Kulkarni 14-Jun-12 3:31am    
downvote countered!
Hi ,

You can use a user control(ascx) and place it on every page that needs this common logic. Furthermore if you have different case scenario you can set different property values in the different pages...

e.g
in page 1
C#
<uc1:testuc id="TestUC 1" runat="server" data="1" xmlns:uc1="#unknown" />


in page 2
C#
<uc1:testuc id="TestUC 1" runat="server" data="2" xmlns:uc1="#unknown" />


Regards,
T
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900