Sounds to me like your code for setting the hidden field's value always sets it to "value". You should either review that for faulty logic or post it here for others to see.
Ah. You are falling victim to a new feature in Web Pages 2: Conditional Attributes. If an expression that is provided as an attribute value resolves
to the boolean true, the attribute name is repeated as the value. This works well for
selected, or enabled, or checked, but not for value. To prevent that from happening, you should convert the variable to a string:
My site seems fine to me. Must have been a temporary flux in the force.
The / creates a self-closing tag: http://xahlee.info/js/html5_non-closing_tag.html. It's not required for HTML5 (the default doc type of Web Pages) but it is for XHTML, and I am a creature of
deeply ingrained habit.
wavemaster
Participant
1279 Points
1127 Posts
bool in form turns into "value" after Post
Dec 06, 2012 02:32 AM|LINK
I have a bool isdeleted that I am passing on with the form data as a hidden value.
Before the Post it is either true or false.
Then after Post I have:
var deleted = request["isdeleted"]
I am left with "value", regardless of the boolean was true or false.
Obviously doing something wrong but I don't see it.
kedarrkulkar...
All-Star
34401 Points
5529 Posts
Re: bool in form turns into "value" after Post
Dec 06, 2012 02:52 AM|LINK
how? you should have converted into string while storing
also, try this
var deleted = Request.Form["isdeleted"].ToString()
KK
Please mark as Answer if post helps in resolving your issue
My Site
Mikesdotnett...
All-Star
154887 Points
19862 Posts
Moderator
MVP
Re: bool in form turns into "value" after Post
Dec 06, 2012 04:48 AM|LINK
Sounds to me like your code for setting the hidden field's value always sets it to "value". You should either review that for faulty logic or post it here for others to see.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
wavemaster
Participant
1279 Points
1127 Posts
Re: bool in form turns into "value" after Post
Dec 06, 2012 01:04 PM|LINK
isdeleted coming back as "value" is indeed the problem.
In my dialog I have a few tabs.
One of the tabs I use isdeleted as a boolean to make a decision on what to show on that tab.
At another tab I have this as part of a form:
After the Post I have this:
In Visual Studio I can see that delete = "value" and is a string
Is it possible to pass a boolean in a form?
Mikesdotnett...
All-Star
154887 Points
19862 Posts
Moderator
MVP
Re: bool in form turns into "value" after Post
Dec 06, 2012 01:22 PM|LINK
Ah. You are falling victim to a new feature in Web Pages 2: Conditional Attributes. If an expression that is provided as an attribute value resolves to the boolean true, the attribute name is repeated as the value. This works well for selected, or enabled, or checked, but not for value. To prevent that from happening, you should convert the variable to a string:
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
wavemaster
Participant
1279 Points
1127 Posts
Re: bool in form turns into "value" after Post
Dec 06, 2012 01:51 PM|LINK
Now that I am officially a certified victim of Web Pages 2, I thought I look up what Conditional Attributes are.
Firefox cannot find the server at mikesdotnetting.
wavemaster
Participant
1279 Points
1127 Posts
Re: bool in form turns into "value" after Post
Dec 06, 2012 02:00 PM|LINK
.ToString()" />
Why is the / there?
Mikesdotnett...
All-Star
154887 Points
19862 Posts
Moderator
MVP
Re: bool in form turns into "value" after Post
Dec 06, 2012 02:57 PM|LINK
My site seems fine to me. Must have been a temporary flux in the force.
The / creates a self-closing tag: http://xahlee.info/js/html5_non-closing_tag.html. It's not required for HTML5 (the default doc type of Web Pages) but it is for XHTML, and I am a creature of deeply ingrained habit.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
wavemaster
Participant
1279 Points
1127 Posts
Re: bool in form turns into "value" after Post
Dec 06, 2012 03:10 PM|LINK
tried your site again just now, same "error loading page"
Sam result from other IE as from Firefox
Mikesdotnett...
All-Star
154887 Points
19862 Posts
Moderator
MVP
Re: bool in form turns into "value" after Post
Dec 06, 2012 03:57 PM|LINK
Just remoted on to the server. It's fine. Nothing in the event log. No problems. Must be something closer to your home.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter