Set Value From ViewData?

Dec 2, 2010

Having trouble here and not quite sure how to do it. I've attempted jQuery but with no luck. I have an object and on my create view, I have a parentId that I want to set (it's in the url as well). So, I'm trying to use Html.HiddenFor so it will populate my new object when returned on the post. BUT, this doesn't work. I've tried the following but it never returns the value on the post.[code]...

As you can see, on doc ready, I set the hidden parent id input with the value from the viewdata because the HiddenFor doesn't have a value attribute. The HiddenParentId field DOES in fact have the value that I'm setting because I'm alerting it and it's got the GUID that it should have. Now, first, I'm using VB so any help in VB would be greatly appreciated and second, if there's another method to solve this issue, please advise. All I'm trying to accomplish is to get the ID that was passed in the URL (which in the controller I'm grabbing that id and putting it in the ViewData) and set the ParentId property of my object for the post so that it will save it when the object is returned to me.

View 1 Replies


ADVERTISEMENT

Error : BC30451: 'ViewData' Is Not Declared

Aug 16, 2011

I have a MVC3 application which uses Devexpress controls.My first page works fine, but this is not strongly typed.I get the error "BC30451: 'ViewData' is not declared. It may be inaccessible due to its protection level" on my second page which starts with:

@ModelType IEnumerable(Of MyModel.XXX)
@Code
ViewBag.Title = "Index"

[code].....

View 1 Replies

Error : 'ViewData' Is Not Declared. It May Be Inaccessible Due To Its Protection Level

May 9, 2012

Dont have any intellisense when creating a sample MVC3 app.Config files are fine, project compiles and works as it should when ran...Have MVC3 & MVC4 installed, same thing with each.Have VS2010 & VS11 installed (running fine side by side), same thing here... no intellisense.

Errors:'ViewData' is not declared. It may be inaccessible due to its protection level.'Url' is not declared. It may be inaccessible due to its protection level.'Partial' is not a member of 'System.Web.WebPages.Html.HtmlHelper'.'ActionLink' is not a member of 'System.Web.WebPages.Html.HtmlHelper'.

The 'ActionLink' error should be trageting the Mvc library should it not?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved