asp.net-mvc-views

How do I upload a file to Azure blob storage from a MVC view

放肆的年华 提交于 2019-12-06 03:58:33
问题 I am coding a MVC5 internet application and would like some help to upload a file from my own filesystem to an Azure Blob. Here is my Azure upload code function: public void UploadFileToBlobStorage(string containerName, string blockBlogName, string fileName) { // Retrieve storage account from connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); // Create the blob client. CloudBlobClient blobClient

Having to repopulate viewmodel when modelstate is invalid due to not sending all data in such as drop down box list

半腔热情 提交于 2019-12-05 15:39:49
In my project I create a survey, I link this survey to a company and select users to participate. I select survey template, add extra questions and sets information about the survey such as start and end date. All in all the result is a complex view with data from many parts of the domain. I created a ViewModel for this view that would include things such as a list for all companies (because i need to select company in a drop down list). Now the annoyance is that when i submit to save, if i have a modelstate error then i want to redisplay the view but since all the data i fetched such as list

ASP.NET MVC Render View to a string for emailing

倾然丶 夕夏残阳落幕 提交于 2019-12-04 21:54:01
问题 I want to use MVC views to create the body for an email and I have come across this (http://www.brightmix.com/blog/renderpartial-to-string-in-asp-net-mvc/) but it doesn't seem to work with strongly typed views (ViewContext is null). But I was after something the would render a full view including a masterpage. I thought that if there was a way of just invoking a view with out redirecting and just writing to a different stream and sending the email within the controller that might do it, but I

How do I upload a file to Azure blob storage from a MVC view

醉酒当歌 提交于 2019-12-04 07:46:45
I am coding a MVC5 internet application and would like some help to upload a file from my own filesystem to an Azure Blob. Here is my Azure upload code function: public void UploadFileToBlobStorage(string containerName, string blockBlogName, string fileName) { // Retrieve storage account from connection string. CloudStorageAccount storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnectionString")); // Create the blob client. CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient(); // Retrieve reference to a previously created container.

How to bind Dictionary type parameter for both GET and POST action on ASP.NET MVC

假装没事ソ 提交于 2019-12-04 04:40:35
问题 I want to define a view which displays a list of label and checkbox, user can change the checkbox, then post back. I have problem posting back the dictionary. That is, The dictionary parameter for the post method is null. Below are action method for both GET and POST action: public ActionResult MasterEdit(int id) { Dictionary<string, bool> kv = new Dictionary<string, bool>() { {"A", true}, {"B", false} }; return View(kv); } [HttpPost] public ActionResult MasterEdit(Dictionary<string, bool> kv

ASP.NET MVC Render View to a string for emailing

孤人 提交于 2019-12-03 13:43:14
I want to use MVC views to create the body for an email and I have come across this ( http://www.brightmix.com/blog/renderpartial-to-string-in-asp-net-mvc/ ) but it doesn't seem to work with strongly typed views (ViewContext is null). But I was after something the would render a full view including a masterpage. I thought that if there was a way of just invoking a view with out redirecting and just writing to a different stream and sending the email within the controller that might do it, but I can't work out how to invoke a view. Any suggestions would be great! Thanks in advance. Gifster

MVC5 view drop down list

天大地大妈咪最大 提交于 2019-12-03 09:03:19
In a C# MVC5 Internet application view, how can I display a dropdown list for a user to select a list item that is populated from a View Model list? Here is the ViewModel code: public class MapLocationItemViewModel { [Editable(false)] public int mapLocationForeignKeyId { get; set; } public List<string> mapLocationItemTypes { get; set; } public MapLocationItem mapLocationItem { get; set; } } Here is the code that I currently have in the View : <div class="form-group"> @Html.LabelFor(model => model.mapLocationItem.mapLocationItemType, new { @class = "control-label col-md-2" }) <div class="col-md

How to bind Dictionary type parameter for both GET and POST action on ASP.NET MVC

有些话、适合烂在心里 提交于 2019-12-01 22:43:18
I want to define a view which displays a list of label and checkbox, user can change the checkbox, then post back. I have problem posting back the dictionary. That is, The dictionary parameter for the post method is null. Below are action method for both GET and POST action: public ActionResult MasterEdit(int id) { Dictionary<string, bool> kv = new Dictionary<string, bool>() { {"A", true}, {"B", false} }; return View(kv); } [HttpPost] public ActionResult MasterEdit(Dictionary<string, bool> kv) { return RedirectToAction("MasterEdit", new { id = 1 }); } Beliw is the view @model System

Created a new view in MVC 5, opening the new view results in HTTP 404

心不动则不痛 提交于 2019-12-01 20:22:59
问题 When I open the default MVC views(index and create) it work fine, I can add data and get data from the database. When I create a new view it don't work. It gets Http 404. This is even if I duplicate the create view, only with a different file name. Error-message: Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please

Created a new view in MVC 5, opening the new view results in HTTP 404

拈花ヽ惹草 提交于 2019-12-01 19:04:20
When I open the default MVC views(index and create) it work fine, I can add data and get data from the database. When I create a new view it don't work. It gets Http 404. This is even if I duplicate the create view, only with a different file name. Error-message: Server Error in '/' Application. The resource cannot be found. Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. I have follow some forum