Solved

ASP Static Method Access Page Control?

Posted on 2013-11-13
2
1,360 Views
Last Modified: 2013-11-16
I'm attempting to access a Page control and keep getting the ole "object instance error".

Q. How can I code this to work?

Page page = HttpContext.Current.Handler as Page;
Control ctl = page.FindControl("divError") as Control;
ctl.Controls.Add(new LiteralControl("<div style='color: red;'>" + ex.ToString() + "</div>"));
0
Comment
Question by:WorknHardr
2 Comments
 
LVL 16

Accepted Solution

by:
Kamal Khaleefa earned 300 total points
ID: 39647051
if the control in the same page then just call the control id and set the property

if the control in another page for example it is in your master page then use this


 Dim x As LinkButton = Me.Page.Master.FindControl("lnkHome")

where linkbutton is the type of your control(it might be a textbox , label ...etc)
0
 

Author Comment

by:WorknHardr
ID: 39647637
Are you saying that having the code inside a static method doesn't matter?
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question