1

best to show this by code example:

html

<div runat="server" id="PI"> </div> 

c#

protected void addNewProject_Click(object sender, EventArgs e)
{
    PI.attributes.add("z-index", "0");  
}

basically gives me an error saying "the name PI does not exist int he current context."

Any idea why it says that?

1
  • Make sure that your .designer.* file has been updated with a variable for PI. Commented Mar 13, 2014 at 22:18

3 Answers 3

1

Make sure that your .designer.* file has been updated with a variable for PI. Some source control systems lock the file and prevent Visual Studio from automatically updating the file.

If the variable hasn't been created for you, you can always go back to your .designer file and add the new variable yourself. Just follow the patter for your other ASP.NET controls.

You're looking for a partial class with the same name as your code behind class.

This SO question addresses your issue as well.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the quick response, I will try that out!
1

I found an alternative solution, instead of making the image switch z-indexes, I am making the asp.net panel switch z-indexes. For some reason when I try to declare my object in designer.cs file...it registers in code behind. This is good, however right when I test it out on a web-browser, the designer file auto-regenerates and gets rid of it again. So instead of playing around with the html controls I played around with what I know works and used the asp.net panel controls.

Comments

0

I always declare them in my codebehind file, something like this:

var myDiv = new HtmlGenericControl("div");

Then you just treat it the same as any other control on your page.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.