Solved

Cannot find control on my page

Posted on 2006-10-25
6
248 Views
Last Modified: 2008-01-09
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
Comment
Question by:dba123
6 Comments
 
LVL 9

Expert Comment

by:HappyFunBall
Comment Utility
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
 
LVL 9

Expert Comment

by:HappyFunBall
Comment Utility
I said reference a few times in that response, but I mean declaration...
0
 
LVL 6

Accepted Solution

by:
Roopesh_7 earned 500 total points
Comment Utility
hey add this

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

to your code behind page...else build your project once more...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 15

Expert Comment

by:Solar_Flare
Comment Utility
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
 
LVL 6

Expert Comment

by:Roopesh_7
Comment Utility
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
 
LVL 2

Expert Comment

by:apgourlay
Comment Utility
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now