Click here to Skip to main content
15,898,222 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have controls like Label ,Text Box etc inside ContentPlaceHolder in Default.aspx page
I want to access same control from Class.cs inside AppCode folder through functions or
Can I pass Default.aspx Page as parameter?
Posted

why? you simply are breaking the whole notion of abstraction. First of all, you will not get into Class.cs with out some sort of event/code. Why do you need to access the controls from Class.cs. Let Class.cs do whatever logic you need to do and handle all control related functionality on from Default.cs
 
Share this answer
 
Comments
saifulhaque 7-Aug-10 2:10am    
Actually I am trying this ,I am giving an example

In Class1.cs

public static string GetControl()
{

Label Label1 = new Label();
Label1.Text = "City Name";
TextBox TextBox1 = new TextBox();
TextBox1.Text = "London";

//Controls inside ContentPlaceHolder Default.aspx

}

In Default.aspx

Default.aspx page contains Label1,TextBox1 under ContentPlaceHolder

I want to get Label1.Text="City Name" and TextBox1.Text="London" is it possible.

protected void Button1_Click(object sender, EventArgs e)
{
Class1.GetControl();
}
koool.kabeer 7-Aug-10 5:47am    
where is your Button1_Click Event Handler... ?
koool.kabeer 7-Aug-10 5:48am    
i think you are trying something new...
AS someone else said, what you want to do is an abortion. You need to fix your design. You COULD pass your page through, using 'this', but, again, it's horrible, I'd fire anyone who did that, on the spot, because I'd feel that their understanding of basic elements of software design were too far gone to be redeemed.
 
Share this answer
 
Comments
saifulhaque 7-Aug-10 2:10am    
Actually I am trying this ,I am giving an example

In Class1.cs

public static string GetControl()
{

Label Label1 = new Label();
Label1.Text = "City Name";
TextBox TextBox1 = new TextBox();
TextBox1.Text = "London";

//Controls inside ContentPlaceHolder Default.aspx

}

In Default.aspx

Default.aspx page contains Label1,TextBox1 under ContentPlaceHolder

I want to get Label1.Text="City Name" and TextBox1.Text="London" is it possible.

protected void Button1_Click(object sender, EventArgs e)
{
Class1.GetControl();
}
koool.kabeer 7-Aug-10 5:46am    
yeah... you are going totally if different way...
fix your design...

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