3

this might be simple, but I can't find information about it.

Why is the aspnethidden CSS class missing from the div's around hidden form fields in my development environment and not on the production environment? It looks like this:

<div>
    <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="..." />
    <input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" />
    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="..." />
</div>

instead of this:

<div class="aspNetHidden">
    <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="..." />
    <input type="hidden" name="__VIEWSTATEENCRYPTED" id="__VIEWSTATEENCRYPTED" value="" />
    <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="..." />
</div>

The server and my dev machine are running on .NET Framework 4.6.1 and IIS is configured to use the .NET CLR 4.0 in the application pool.

I'm just curious to know why this is missing on my Windows 10 Dev machine.

1 Answer 1

1
+50

The one which you are observing is a New feature .It is about the hidden fields in ASP.Net 4.0.

You probably might aware that ASP.Net is using hidden fields as a state control mechanism. It is used to preserve Viewstate and Control state.

They are usually included in a div element, <div></div>.

I have created a sample asp.net application in VS2010 and .Net 3.5

when i see my view source i'm able to see something like this

<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/rxyklmnLTQ0NTA1Mstupvmjk8I5q9vNjFXLeK/1IBsUwBM=" />
</div>

when you apply any css rules for div elements in your external css file, those rules that apply for all div elements in your code, will apply for that <div> that surrounds the hidden field elements that dealing with the viewstate.

When you create the application with the Asp.net 4.0 will render with CSS class around div

<div class="aspNetHidden">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="..." />
</div>

Based on My Research here are some Souces which will elaborate more

  1. how-to-handle-the-div-tag-around-asp.net-hidden-inputs.aspx
  2. ASP-NET-SEO-around-VIEWSTATE
  3. hidden div elements in asp.net 4.0

Update

In your dev machine , you might have set the

controlRenderingCompatibilityVersion="3.5" 

so that is the reason you are unable to see that class aspNetHidden in your dev machine as that feature was introduced in Asp.net 4.0

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

7 Comments

thx, but this is not really helping. I know that ASP.net 4 introduced the class to hide the inputs and I know what it is for. What I don't get is why it is not rendered in my application when I run it with ASP.NET 4?
@spankmaster79 your dev iis version and your serve iis version? and just to confirm , you are using asp.net 4.0 and more?
dev iis version is 10, prod iis version is 8. Application Pool and framework see above
@spankmaster79 can you post you dev webconfig ?
which part. Don't want to post the whole thing. It's huge and contains sensitive information
|

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.