can not access control in markup page (VS2008)

  • Thread starter Thread starter Ryan Liu
  • Start date Start date
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
 
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
 
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"
 
Back
Top