Solved

ASP Static Method Access Page Control?

Posted on 2013-11-13
2
1,410 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

726 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