Search Results

Search found 3 results on 1 pages for 'thinknow'.

Page 1/1 | 1 

  • Validating only selected fields using ASP.NET MVC 2 and Data Annotations

    - by thinknow
    I'm using Data Annotations with ASP.NET MVC 2 as demonstrated in this post: http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx Everything works fine when creating / updating an entity where all required property values are specified in the form and valid. However, what if I only want to update some of the fields? For example, let's say I have an Account entity with 20 fields, but I only want to update Username and Password? ModelState.IsValid validates against all the properties, regardless of whether they are referenced in the submitted form. How can I get it to validate only the fields that are referenced in the form?

    Read the article

  • Dynamically assigning properties on a non data bound ASP.NET control

    - by thinknow
    For example, let's say I have a HyperLink: <asp:HyperLink runat="server" Text="Foo" NavigateUrl="foo.aspx" /> How can I set the NavigateUrl on the server side, without having to go the code-behind? This doesn't work of course: <asp:HyperLink runat="server" Text="Foo" NavigateUrl="<%= urlString %>" /> (where urlString might be a string I created earlier in the page) And this doesn't work because the HyperLink is not within a data bound control: <asp:HyperLink runat="server" Text="Foo" NavigateUrl='<%# urlString %>' /> I guess I could just use a standard anchor element: <a href="<%= urlString %>">Foo</a> But I'd rather not mix up HTML and ASP.NET controls, and it would be handy to be able to do this for other controls. Surely there must be a way?

    Read the article

1