Solved

Cannot find control on my page

Posted on 2006-10-25
6
256 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
[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
6 Comments
 
LVL 9

Expert Comment

by:HappyFunBall
ID: 17807102
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
ID: 17807110
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
ID: 17807449
hey add this

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

to your code behind page...else build your project once more...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 15

Expert Comment

by:Solar_Flare
ID: 17809098
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
ID: 17812480
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
ID: 17813456
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

707 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