.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Upload with strongly-typed view - Create Method

Posted By:      Posted Date: October 25, 2010    Points: 0   Category :ASP.Net


How to can upload a file to database with strongly typed view - create method?

Picture is a binary db column

<%: Html.TextBoxFor(Function(model) model.Resim)%>


 How i can translate "TextBoxFor" to "UploadFileFor"?

View Complete Post

More Related Resource Links

How to create strongly typed datasets with access parameter queries



How can you create strongly typed datasets using an access database against access select statements that use parameters?

The problem is VS.Net doesn't allow select queries with parameters to be dragged onto a form, it only allows access queries without parameters!

I also tried the dataadapter wizard, but again it only allows me to select queries without parameters?

Many thanks in advance


binding dictionary with strongly typed view

hey guys ,i m beginner in asp.net mvc , i have strongly typed view and i m passing my dictionary in view as :Dictionary<Guid,IYummyWebAppMVC.Models.Restaurant.Menu>>" %> Dictionary<Guid , MyApp.Models.Res.Menu>  how do i access this in html ?how do i iterate thru it and get value of both the items ?

strongly typed view - Complex Model

I have a class ProjectDetailModelView with       ProjctDetail (fields to display)        UserList - SelectList (for dropdown control)I pass in  Inherits="System.Web.Mvc.ViewPage<glossaryDB.Manager.ProjectDetailModelView>" %>       And I want to use something like the following:<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">    <h2>Project : Edit</h2>     <% Html.EnableClientValidation(); %>    <% using (Html.BeginForm()) { %>        <fieldset style="padding: 1em; margin: 0; border: solid 1px #999;">            <%= Html.ValidationSummary("Broken stuff:") %>               <%= Html.EditorForModel() %>            <input type="submit" value="  Submit  " />   

Strongly typed view validation


I have a strongly typed view with my model being entity framework.  In my controller I check for ModelState.IsValid.  When I submit my form without a value for a column that does not allow nulls it crashes before it gets to the ModelState.IsValid line and the error is about not allowing nulls in the column.  Shouldn't this be what is handled by the ModelState.IsValid line?  I feel like I am missing something obvious. 

Using a partial in a strongly typed view


I have an application that is going to allow a user to create records of type Customer and Seller that have one section in common, but other fields that are unique to their types.

Both of these types will have an address block for their create view.

If I have a strongly typed Customer or Seller view, how can I use the view partial (containing the address block) that I've created? I've tried creating a view model, but I don't know how to have the create page inherit the Customer model and the addressBlock partial inherit the addressBlockForm partial model...

Hopefully, this makes sense, and thank you for any help.

Strongly typed view and viewModel


Hello together,

I have a question about strongly typed views.

I already have my business objects (based on the persistence framework xpo form dev express). These objects have some associations.

eg. an article can have some user comments


My question now is, should my strongly typed views directly base on this objects (even if these objects have many properties i never need to present)

or should i create additional classes containing only the properties of the objects which i like to present.

eg. articleViewModel and commentViewModel.

where a articleViewModel can have associations with multiple commentViewModel

The advantage which i see in the second example is, that i can easier validate the viewModels.

However it means a lot of extra work, because i need to create for all objects which i like to present a viewModel with the corresponding

associations and properties.

Thanks a lot!

Regards Vincenzo

MVC2: Change the default generated HTML when creating a strongly typed view


Is there any way to change the HTML that is generated by default when you create a strongly typed view in MVC2?

I currently get a structure like this:

            <div class="editor-label">
                <%: Html.LabelFor(model => model.category_id) %>
            <div class="editor-field">
                <%: Html.TextBoxFor(model => model.category_id) %>
                <%: Html.ValidationMessageFor(model => model.category_id) %>

I want to change it to a structure like this:

                <div><%: Html.ValidationMessageFor(model => model.user_login) %></div>
                <div><%: Html.LabelFor(model => model.user_login) %></div>
                <div><%: Html.TextBoxFor(model => model.user_login) %></div>

Strongly Typed HtmlHelpers and View Models



I am not sure why this happens, but when I have an Html.TextBoxFor(model => model.SomeObject.SomeProperty), when I post, the property of that object is always null.

When I look at the markup generated, I see <input type="text" name="SomeObject_SomeProperty" id="SomeObject.SomeProperty" value = "" />

If I change the helper to Html.TextBoxFor(model => model.SomeObject.SomeProperty, new {id = "SomeProperty"}) the controller is then able to pick the value up. Why is this happening? I feel as though I shouldn't have to be specifiying the id for the textbox as it works when fine when not using child objects on a view model, IE <%: HtmlTextBoxFor(model => model.SomeProperty) %>.

Downcasting to base class Strongly typed view


I have the following entity object:

    public class ForumPost
            public virtual int ForumPostId { get; set; }
            public virtual int LoginId { get; set; }
            public virtual string Body { get; set; }

Then I have page that would has a list of ForumPost(s) and and edit option, all on one page. To achieve this I've created a CommentsViewModel that extends "ForumPost" class like so:

    public class CommentsViewModel : ForumPost
        public IPagedList<ForumPost> ForumPostList { get; set; }

This way on my view I can have a list of ForumPost(s) and a form that would edit the post.

This is what i see in the debug mode right before the save call:

The problem is that when I try to Save/Update I get the following error:

I already tried doing this:



REST WCF service. Unable to create Upload method for binary


I want to create a REST WCF service that can receive an image (binary).

Following this and this article I still cannot get it working. Only difference is I use IIS as host for my service, which means it runs in Cassini webserver.

I have this ServiceContract:

    public interface IImages

        [WebInvoke(UriTemplate = "UploadFile/{fileName}")]
        void UploadFile(string fileName, System.IO.Stream fileContents);


I then also have this class:

Create and Use a Typed DataSet by Using Visual C# .NET

This article shows you how to create and use a typed DataSet in a small Web application. Typed DataSets, which inherit from the DataSet class, create first-class members of a DataSet's DataTables and DataColumns, yielding the many benefits that come with the use of strong typing.

Introduction to strongly Typed Data Sets

This article teaches how to create a strongly-typed dataset class library in your C# database applications. Our objectives are as follows:

.Learn what an strongly-Typed Data Set is
.Let Visual Studio Create a ST Data Set
.(Semi)Manually create a ST Data Set using XSD (Xml Schema Definition)

Data Points: Efficient Coding With Strongly Typed DataSets


Someone once said to me that the hallmark of a good developer is the desire to spend time efficiently. Developers are continually pursuing ways to make coding easier and faster, and to reduce the number of errors.

John Papa

MSDN Magazine December 2004

file upload in Create User Wizard Created User event with UpdatePanel Tag wont work?



In my Create User Wizard1 Created User Wizard Event, I am collecting extra information from text boxes and allowing

the user to uplad a file.



I have put the Submit button within an Update Panel Tag but since I have done this it does not work.

Is there a way round it. In this situation would you use a trigger.?


<br />

  <asp:UpdatePanel ID="UpdatePanel2" runat="server">

  <asp:Button ID="StepNextButton" runat="server"  CommandName="MoveNext"  align="middle"
                                            Text="Submit my Profile" />

How to create scrolling table for columns in a SharePoint Designer Data View


I have a fairly complex SharePoint Designer 2007 Data View they have added two more requirements.

1. Have the columns on the right side be able to scroll left to right as there is a large number of columns, while the first 3 columns on the left side stay locked in place.  This is only one list not two, and because of some other requirements I have it must remain to be just one list.

2. Then they also need to have scrolling up and down of the entire list with the headers locked in place.

The first requirement is more important than the second, but preferrably I need to do both.

I am new to XSL so not familar with the syntax. Is this something I can do on a custom Data View? Does anyone have any examples of how?

I have a drawing that show how it needs to look but I don't see an option here to upload a graphic.

So here is a link to my graphic example uploaded to my blog area: http://lindachapman.blogspot.com/  or just the image here: http://4.bp.blogspot.com/_aB01ue__NvQ/TGL42MOvrGI/AAAAAAAAAA4/c3xP4uCy4BU/s1600/Scrolling.png

I failed to mention that 3/4 of the columns are HTML Calculated fields wh

why I can not upload file to web by using WebClient.UploadFile method?



I am using WebClient.UploadFile method to upload a file to a web page.

The code is like this:

WebClient client = new WebClient(); 
byte[] responseBinary = client.UploadFile(url, fileName); 
string response = Encoding.UTF8.GetString(responseBinary);

But I can not upload it to server.

I used fiddler to see what happens, and it shows me the following information:

http status code: 302, request headers: POST /testing/upload/default.aspx HTTP/1.1

http status code: 302, request headers: GET /testing/upload/default.aspx?AspxAutoDetectCookieSupport=1 HTTP/1.1

http status code: 200, request headers: GET /(X(1)S(22pynhvxd3eqsb455pudx145))/testing/upload/default.aspx?AspxAutoDetectCookieSupport=1 HTTP/1.1

I would like to know, why I get 302 code, and why it redirect me to the strange url with (X(1)S(22pynhvxd3eqsb455pudx145)) ?

By the way, the web page is ok to upload file by using web explorer.


create a dynamic view on code

How i can create a new view on code (on runtime) if this view dont exits?   Thanks
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend