I'm beginner in ASP.NET MVC. So i have simple question. I'm create sample MVC 2 web project in 2010 RC. Add SQL Database with one table of products. I'm using Enity Framework as data access method. Table contain colums Id, Brand, Description, Price. I have one controller with Select and Show Actions tyhat whould shows apropriative views. And Question: I want to select brands (multiple checkboxes) of product manufacturer on Select page and show list of products on Show page. But i can't understand how to pass data (wich checkboxes is selected) from one page to another
I am using ASP.NET MVC2 for my project. I want to send the user confirmation messages after actions.
Ideally: User clicks on a link with a query string (i.e. a link to delete an entry) The controller does what the link says, creates the success message, and uses RedirectToAction to get rid of the query string from the URL. The new action displays the success message.
Table Product Product Id Product Name Table ProductSupplier ProductSupplierId ProductId SupplierId Table Supplier SupplierId SupplierName
I have the above 3 tables in my database, ProductSupplier is the lookup table. Each Product can have many suppliers. I am using Entity Framework. Using Web Forms it was fairly easy to display a Product on a web page and bind a repeater with the suppliers information. Also, with Web Forms it was easy to Add new Product and suppliers, the linkage seemed easy.
How do you do this sort of functionality in MVC? In the Create View below, I want to be able to Add the Supplier as well. Is there a better approach that I might be missing here? This is how I did it with Web Forms. Beyond the code below I am totally lost. I can show data in a list and also display the Suppliers for each Product, but how do I Add and Edit. Should I break it into different views? With Web Forms I could do it all in one page.
namespace MyProject.Mvc.Models { [MetadataType(typeof(ProductMetaData))] public partial class Product { public Product() { // Initialize Product this.CreateDate = System.DateTime.Now; } } public class ProductMetaData { [Required(ErrorMessage = "Product name is required")] [StringLength(50, ErrorMessage = "Product name must be under 50 characters")] public object ProductName { get; set; } [Required(ErrorMessage = "Description is required")] public object Description { get; set; } } public class ProductFormViewModel { public Product Product { get; private set; } public IEnumerable<ProductSupplier> ProductSupplier { get; private set; } public ProductFormViewModel() { Product = new Product(); } public ProductFormViewModel(Product product) { Product = product; ProductSupplier = product.ProductSupplier; } } } ProductRepository public Product GetProduct(int id) { var p = db.Product.FirstOrDefault(por => por.ProductId == id); p.ProductSupplier.Attach(p.ProductSupplier.CreateSourceQuery().Include("Product").ToList()); return p; } Product Create View <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MyProject.Mvc.Models.ProductFormViewModel>" %> <%= Html.ValidationSummary("Please correct the errors and try again.") %> <% using (Html.BeginForm()) {%> <fieldset> <legend>Fields</legend> <div class="editor-label"> <%= Html.LabelFor(model => model.Product.ProductId) %> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.Product.ProductId) %> <%= Html.ValidationMessageFor(model => model.Product.ProductId) %> </div> <div class="editor-label"> <%= Html.LabelFor(model => model.Product.ProductName) %> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.Product.ProductName) %> <%= Html.ValidationMessageFor(model => model.Product.ProductName) %> </div> <div class="editor-label"> <%= Html.LabelFor(model => model.Product.Description) %> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.Product.Description) %> <%= Html.ValidationMessageFor(model => model.Product.Description) %> </div> <p> <input type="submit" value="Create" /> </p> </fieldset> <% } %>
I am trying to make some sense of this validation stuff in MVC2. I followed various walkthroughs, all them for betas/rcs... and I cant' get anythign to happen. Note: THIS JQUERY - NOT THE MS AJAX STUFF!I have referenced MicrosoftMvcJQueryValidation.js which i got got the mvc2 futures lib.
My model is:
[Code]....
The form bit of my ViewPage<User>:
[Code]....
As far as I can see the only additional thing that is being rendered is this:
[Code]....
Which is interesting/annoying for a few reasons. Firstly all of my annotations appear to have been ignored.Secondly FormId isn't even marked as required, and as this rendered text was taken from a page loaded with a null Model (add mode) the FormId field isn't in the form. Finally, this doesn't even result in any actual validation occuring (on the client side). All the server side validation is working fine.See I am using PasswordFor instead of EditorFor. Because someone at MS testing dropped the ball there. Yes EditorFor renders a password field, but it behaves differently to PasswordFor.. the value of the Password field is sent to the client (set in the value attribute of the field). Fail.
one thing that has been puzzling me since learning MVC2 is the following case scenario: I have a view which contains two latest news lists, a login form and a signup form. Every example I found on Views and View Models so far has a one-to-one example such as a simple login form etc. But how do I create a model that provides the properties and validation for a login and signup form and manages the data for the news lists. can I pass multiple models in the strongly typed view? When I created one model the form validation would fail as it expects all fields - login and signup to be filled. I am missing some advanced examples or information.
I have a ListView displaying data from Table A using a SqlDataSource.
I want to take the displayed data (and these are just the standard columns representing fields in Table A) and store them in Table B using a Stored Procedure
(The scenario is much more complex but I've left out anything not relating to this exact problem).
I've added a Button to the ListViews ItemTemplate and I'm using OnItemCommand to create a Sub for its "Click" in the Code Behind.
This is a simplified chunk of the SQL I'm using to insert the ListView's fields into Table B using the Stored Procedure "InsertCart":
[Code]....
Where I've highlighted "Description" in the last line. In a GridView, this would be enough. Description is a Column name in Table A and B and iy's an Item in the ListView. But I'm realising that, with ListView's, the data binding is not as "automatic" as a GridView. Just using the columnname is not enough.
What do I use instead of the word Description to reference this column in the Parameter?
I have a gridview and I have an edit template for one control. I have a drop down box in this edit template so that you can select a value from it and then when you hit 'Update' the value from the drop down box is committed to the updated record. Unfortunately when I do hit the update button I get a fault that the "Status" field cannot be null.
Here is the code that picks the value from the drop down value and assigns it to the new values list:
I need to be able to evaluate the text value of the template button or pass date from the dbDateOpened colum when the button is pressed. Either direct I have tried gives me an compile error. With the current configuration I get this error. "Object reference not set to an instance of an object."
I'm using the DetailView control to display employee details from a specfic company, but it seems when I try to create the query in the data source wizard I'm unable to select the variable for the WHERE clause, only the web pages control components.
The employees are selected through the company name which is entered at the beginning of the page and in turn is used to select the company id.
In my asp.net web page i have a dropdown box. Say like i have to bind EmployeeName to this dropdown box to show up as items.
I am using a dataTable to bind to this grid by having two columns in DataTable (EmployeeId and EmployeeName). But i am only binding the EmployeeName to the dropdown list box.
In the UI, after the user selects an Employee, I need to pass that employee's id to a function. Is there any way, i can directly pass the underlying data (EmployeeID in the DataTable attached to this dropdown), when the user selects the EmployeeName from the dropdown. Or i will have to make a roundtrip to the database and get the selected Employee's Id and then pass it to the function.
I have some doubt about GridView PageSize, for the example if my table have more than 100000 rows and i set PageSize=50, i can see GridView trying to download whole 100000 rows and display only 50 records with pagewise.
In this case my application getting very slow.
Is there anyway to force GridView download data according to the pagesiz without passing limit in sql?
I have some doubt about GridView PageSize, for the example if my table have more than 100000 rows and i set PageSize=50, i can see GridView trying to download whole 100000 rows and display only 50 records with pagewise.
I have two tables: Book and author and they have one to many relation.One book may have more than one authors. Book table has Title column and Author table has AuthorName Column.
I have search page contains two textboxes: Title Textbox and AuthorName textbox to search the record.
When the user type something and hit the search button it display the Title when click the title ; it redirect to detailsPage.aspx Passing value ID.
[Code]....
Then in the Details page there are: Title, authors and other more from these table column.
My problem is:
When the user search and hit the search button, it display the number of matches Title only. I want to display authors related to this title in this page and other are same(when click the title go to detailspage.aspx)
How can I display the related Authors to each title in search display page (Not in details page, I know in details page) ?
If user search "The Letters and life" in the Title textbox and hit enter data should looks like:
1. Author: Payne Paddy, sed ran, der virma and Caroline Barron.
Title: The Letters and Life of Elizabeth Despenser, Lady Zouche (d. 1408) [her letters and will provide a glimpse of her personal
I have a page where there are two nested gridview, I have a column in the child gridview that uses a function to display the data.This function uses the id of the id of the father and son as parameters. I tried the code below, but does not work ...
I have a DetailsView that I am trying to use to pass results to an applet's parameter list but I can't figure it out.
Example:
<asp:DetailsView ID="...".... <Fields> <asp:boundfield Datafield="Name".../> <asp:boundfield Datafield="Name2".../> ...etc. <applet codebase="http:/..." ...> param name="Name" value="value of Name from my DetailsView" /> param name="Name2" value="value of Name2 from my DetailsView" /> ...etc.
I have been trying all sorts of things and viewing tutorials, etc, but I just don't seem to be able to figure this out.
I would like to implement the following functionality between 2 web applications:
a) Web application one contains a button, which, when pressed launches another web application.
b) The second application contains a form that is filled in by the customer.
c) After filling in the form, the second application validates the information and returns a 5 digit code to indicate whether validation was successful.
d) Web application one then displays the status and asks the user to continue with other steps.
Is the above scenario possible? Is it possible to transfer data between 2 seperate web applications? I have considered using a query string, database and flat file to trasnfer the data from one application to another. Which of these (if any) would be the best choice?
Is there any way to pass a List<T> that's generated during the page load process to a Javascript function that's called when the user presses a button without having to manually serialize/deserialize the data every time (such as is the case with XML/JSON cookies)?
I have few fields which when entered data by the user,they pass to the database and another webform called registration calls this values, there was an error in this when I looked into the registration form there was one field which was not showing up the data
then I looked into the database and found that the webform 1 is actually not passing the data of a field named "issuedate" to the database at all.
I posted the code for issue date can someone plzzz look at the code and tell me what could be wrong becoz I tried looking at this but couldnt understand what was happening HTML CODE FOR ISSUE DATE
I have a repeater, where all items have a textbox and a submit button. As I see I can not assign to any property (even to a hidden input field) the ID of the row I am displaying, so I don't know how to process the submission of the form.
[Code]....
how to get which button was clicked and retreiving the value from the corresponding textbox, and also passing somehow the product_code?
I need to design two apps who can interact with each other. The first app, App A needs to send an encrypted string over to App B and App B will have to decrypt it and do some stuff. How would I go about that?
App A - http://MachineA/default.aspx App B - http://MachineB/default.aspx
I tried encrypting the data using AESCryptoServiceProvider and it returns a byte[]. Now how would I transfer it over to another application? Via query strings?
trying to pass my drop down list id into my gridview query.
my query works perfectly well in the sqldatasource query wizard but gives
[Code]....
basically i have a flights table and hotel table linked. therefore a flight id exists in the hotel table. i have a drop down which has string values. but i want to pass the string values id to my sql...