• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

Cannot find control on my page

OK, I added the following in my aspx page:

...
<p runat="server" id="paragraph1">some text is here....</p>
...

My codebehind (.cs) has this trying to reference this tag.  Wehave thi working on other projects like this, same code.  But for some reason I get "C:\directorywhatever\mypage.aspx.cs(68): The type or namespace name 'paragraph1' could not be found (are you missing a using directive or an assembly reference?)"  

There is definitely no missing .dll, this is simply referencing an html server-side control now that I put runat="server" id="paragraph1" in that tag

I'm using VS 2003 to build, what could it be?  Why isn't it finding that server tag?

I have othe rpages in thi sproject, aspx pages that are setup like this, and after adding that paragraph tag in, the code-behind for those other pages can see it fine.  It's just on 2 of the pages that cannot find it like this, wondering if I need to add a reference somwhere to make VS 2003 aware of the control?
0
dba123
Asked:
dba123
1 Solution
 
HappyFunBallCommented:
In the code behind file you'll need to add a reference to that new control.  Other controls are referenced at the top of the code behind, usually automatically when you use VS2003 designer to add them to your page.  If you edit the HTML directly, you just need to add the control declaration yourself.

I don't know the C# equivalent off the top of my head, but in VB it looks like this:

"Protected WithEvents paragraph1 as LiteralControl"
0
 
HappyFunBallCommented:
I said reference a few times in that response, but I mean declaration...
0
 
Roopesh_7Commented:
hey add this

protected System.Web.UI.HtmlControls.HtmlGenericControl paragraph1;

to your code behind page...else build your project once more...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Solar_FlareCommented:
have you switched to design view rather than html since you added it? I have found that VS Express editions are not aware of new controls until I have switched to design view. Probably not relavent but thought I would mention it just in case as a possibility...
0
 
Roopesh_7Commented:
yes thats right...if u r swiched to disgn view it is automatically created.... some controls arenot created.. for that we manually add that....
0
 
apgourlayCommented:
The only thing to watch out for in VS2003 is when you switch to Design view it can really mess up your HTML. I'd manually add the reference to code behind page.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now