MVC :: Passing A List As A Parameter With BeginForm()?
Mar 2, 2011
I am using HTML.BeginForm to create a form on my page. I need to pass a list of classes I created as a parameter. It's done like this:
<%
using ( Html.BeginForm("DisplayCompanions", "CCDReviewController", new { CompanionList = Model.CompanionList} ) )
{ %>
When I click a "Continue" button (enclosed in the form tag), the "DisplayCompanions" method on my Controller ("CCDReviewController") should be called, as I've set a breakpoint on it. But it's not being called.
Note that Model.CompanionList is a generic list of classes that I created.
I have an ASP.NET PageMethod with the following signature:
<WebMethod()> _ Public Shared Function SaveCodes(ByVal codes As List(Of Code)) As String
I am trying to pass a JSON object to the PageMethod from the client side, but I get an error that the type String cannot be converted to type of List<Code>.
Here is the json that I'm building on the client and sending to the method:
[code]....
I have been able to pass in simple data types and a single instance of the Code class, but I can't seem to find the magin to pass a List to the server method. Can anyone show me what I'm doing wrong?
each of them is a check box inside this check box list and i have a stored proc that takes paramter which is the name of the city and gives me a data according to the name of the city (Filter). i wana know if i checkec more that one city how can i pass this to the stored proc eg if i checked on cairo and alex what can i do to make the filter looks like this where city Like 'Cairo' and City Like 'Alex' My Stored Proc takes @City Parameter like this Create Proc xx(@City varchar(2)) how can i pass the 2 cities 2 the stored proc
When I put a part of my form in a partial view, all form parts get unobstructive syntax except the form elements in the partial view. The only way I found how to "apply" the unobstructive syntax, is by starting another form inside the partial view.
<input class="text-box single-line" data-val="true" data-val-required="This field is required." id="Name" name="Name" type="text" value=""> <input id="SomeContent" name="SomeContent" type="text" value="0">
So only the input element from the View has the unobstructive syntax and the partial view hasn't... Is there a way to apply unobstructive syntax inside a partial view, wich doesn't require you to begin a new form?
Secondly, how does ASP.NET MVC know that action is my action, and controller is my controller. Like I saw this in samples, and it does work, but isn't it just an anonymous object with no type?
I am opening one page and sending parameter from one asppage to other using winodow.open method
var retVal = window.showModalDialog("PopupWindow.aspx?SQL=" + document.getElementById(SUCName.concat("txtRetVal")).value + "&Curr_Date=" + d , null,"dialogLeft=" + XPos + ";dialogTop=" + YPos + ";center=no;status=no;dialogHeight:430px;dialogWidth:420px;resizable=no;help=no"); in my document.getElementById(SUCName.concat("txtRetVal")).value contains: SELECT ResourceID, ResourceName FROM ResourceMaster WHERE AREA LIKE '%CALICUT%'
but when it access this on PopupWindow.aspx using Request.QueryString("SQL") then first 3 character in LIKE clause gets convert to some ascii character and my query becomes
SELECT ResourceID, ResourceName FROM ResourceMaster WHERE AREA LIKE '�LICUT%'
i am doign url routing and it is working fine with url like followwing:-when ever i click on HOME/SEARCH i get redirected to ~/SEARCH1.aspx page.
[Code]....
BUT IF I REPLACE THE ABOVE URL WITH "~/SEARCH1.ASPX?ID=2"I GOT FOLLOWING ERROR:'~/search1.aspx?id=2' is not a valid virtual path. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Web.HttpException: '~/search1.aspx?id=2' is not a valid virtual path.i have to pass id to the search1.aspx page.what is the way out.
Developing in C#.I have a home page and couple of other aspx pages.In the home page in a summary box I have names of projects. When the user clcks on a given project I will pass the projectID to the Project.aspx page.I then retrieve this ProjectID and display the project details in text boxes. Code is given below.
I tried to pass a string value into a JavaScript function like below: <%= "'" + prop.property_description + "'") %>) But it does not seems to be the best option, is there a better way to do the above without concatenate the string values with "'"?
how to pass through a query string parameter of an assignment id and then checking and validating this as a number and displaying the information returned on screen. At present I have code which displays the information on screen but this is by entering in the assignment id and by triggering the button click event, I've shown the code for this below:
.aspx <div> <b>Current Assignment</b> <br /> <asp:TextBox runat="server" ID="txtAssignmentID"></asp:TextBox> <asp:Button runat="server" Text="Get Assignment" /> <br /> <b>Date Started:</b> <asp:Label runat="server" ID="lblAssignmentStart"></asp:Label> <br /> <b>Status:</b> <asp:Label runat="server"></asp:Label> <br /> <b>Current Achievement Level:</b> <asp:Label runat="server" ID="lblAssignmentLevel"></asp:Label> <br /> <b>Date Last Calculated:</b> <asp:Label runat="server" ID="lblAssignmentCalcDate"></asp:Label> <br /> </div> .cs protected void cmdGetAssignment_Click(object sender, EventArgs e) { //Check the assignmentID is an integer int AssignmentID = 0; try { AssignmentID = TypeConv.CInt(txtAssignmentID.Text); } catch { } if (AssignmenttID > 0) { //Create new TCAAssignment object by passing the ID TCA Assignment Current Assignment = abc.TCA Assignment (AssignmentID); lblAssignmentStart.Text = Current Assignment.dDateCreated.ToString(); lblAssignmentStatus.Text = CurrentAssignment.rTCAAssignmentStatus.dDescription; if (!CurrentAssignment.dTCAAchievementLevel.IsNull) { lblAssignmentLevel.Text = CurrentAssignment.rTCAAchievementLevel.dDescription; } lblAssignmentCalcDate.Text = CurrentAssignment.dAchievementDate.ToString(); } }
Code example passing through a query string parameter of an assignment id would be great.
I'm working on Visual Studio 2008 and SQL Server 2008, language C#
Multiple parameter passing in crystal report in asp.net. I have two parameter @accountnumber and @customerid at time. I can only pass one parameter to my.
I have created an ASP.NET page and included a ReportViewer on the page.
I have created a report with a parameter for an item ID for a row from the database.
After generating a multivalue parameter, I send it to the report, but only the first item in the list is displaying.
In my included code, I am using a FOR loop to generate a list of ID's I want to print a detail for (one detail per page), but eventually I am going to allow a user to select the ID's from a GridView, generate the reports and then print.
Here is the code that build the multivalue parameter:
List<ReportParameter> paramList = new List<ReportParameter>(); ReportParameter param = new ReportParameter("ParmWorkOrderID"); // Create the ArrayList of values to pass ArrayList values = new ArrayList(); for (int i = 19; i < 50; i++) { param.Values.Add(i.ToString()); } // Add the parameter to the list of ReportParameters paramList.Add(param); // Set the reports parameters this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] {param});
I'm experimenting with an example of code that I found in a book. Here is the HTML:
[Code]....
This looks fine in DesignView.
Here is the VB:
[Code]....
The page loads when I hit F5. I enter initials for a state and click the button and get this error message: 'The connectionstring property has not been initialized'. This line is green:
objConnection.Open()
I'm highly confident that the connection srting is correct. Do I need to Dim another variable or something?
I have an asp.net page where I get the user_id from who's logged in. Now I need to pass this user_id to a flex application that runs in an asp.net page as a .swf. How can I get this user_id in a variable in my flex application. Or what is the best way to get the user_id into flex.