can not access control in markup page (VS2008)

R

Ryan Liu

Hi,

These days I encounter some weird problem, when I add server control in
markup xml files, and the switch to code behind to add code to manipulate
it, but seems the definition for the control is not auto-generated in
*.design.cs, so I can not access that control in code behind. But in
runtime, I can see the control is on page, I just can not change its
properties in code behind.

The control ( button, or label) is not in a template. Sometime I try
open/close VS, delete/add control back few times, I can get access to it.

I am using VS 2008 SP1, anyone encounters same problem?

Thanks,
Ryan
 
P

Pete Hurst

Ryan said:
These days I encounter some weird problem, when I add server control in
markup xml files, and the switch to code behind to add code to manipulate
it, but seems the definition for the control is not auto-generated in
*.design.cs, so I can not access that control in code behind. But in
runtime, I can see the control is on page, I just can not change its
properties in code behind.

I assume you are using Web Application Project. This happens to me
sometimes. Usually it's because a warning I haven't noticed is preventing
the template from being compiled.

The way I've found to fix this problem is:
1. Delete the *.designer.cs file
2. Right-click the *.ascx or *.aspx template, and select "Convert to web
application"
3. This will attempt to regenerate the *.designer.cs file, and fire an error
if there are any problems.

Once the problems are fixed, the *.designer.cs file should generate
successfully.

If this doesn't fix it or you can't work out what's wrong, post your code
and any errors here. Sometimes I've found these problems can be quite
cryptic!

Pete
 
R

Ryan Liu

Thanks! Before I receive your mesage, I cut/paste the control few times and
get it works now. I will try to see if I get into trouble again.

I was hoping there is a way to delete *.design.cs and let it auto-generates
it again, and you just point out how to do it, I believe it will work.,
thanks a lot!

Ryan

"Pete Hurst"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top