.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

Submitting a form for a dropdownlist

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

I have a dropdownlist for sorting a table as follows:

<% using(Html.BeginForm(Model.ActionName, Model.ControllerName, Model.RouteValues, FormMethod.Get))
{ %>
   <%: Html.LabelFor(m=>m.Sort) %>
   <%: Html.DropDownList("Sort", Model.Sort, new { onchange = "this.form.submit();") %> 
<% } %>

Which generates something like this:

<form method="get" id="form1" action="/mycontroller/myaction?param1=stuff&param2=otherstuff">
   <label for="Sort">Sort by</label>
   <select onchange="this.form.submit();" name="Sort" id="Sort">
      <option value="1" selected="selected">1</option>
      <option value="2">2</option>

Why does it submit as:


rather than:


Do I need to put param1 and param2 in hidden fields?

View Complete Post

More Related Resource Links

Anonymous users submitting Infopath forms via InfoPath Form Web Part

Is there a way for anonymous users in a public facing site to submit InfoPath List Forms via an InfoPath Form Web Part? Currently when I go to a page with the InfoPath Form web part configured as an anonymous users I get the following error message: Error loading the form A form template (.xsn) file cannot be accessed. You may not have the required permissions to open the file The list allows anonymous users permissions to add and view items When logged in the form works fine

Infopath Form Data submitting to Sharepoint 2010 List

Making a Client intake form that once submitted will send data to  a sharepoint 2010 List called contacts. Short Summary the form will have repeating fields and alot of information to submit. I have looked and read all over but I cannot find an easy step by step guild on how to submit the form data like that. Long Summary on the sharepoint site a button will open a form for adding a new client.  once the form has been filled out and the user hits submit sharepoint will then create a User File, in clients file, and take the data and put it into contacts list. I am trying to make use of Sharepoint as I would with access, meaning the more information I have on a client the easier it will be to mail merge letters, motions, basicly any file prepaired stuff. So once I have css designed forsharepoint to make it look the way I want then the forms should intergrate perfect

Error submitting browser enabled form using this.Submit()

I'm trying to submit my Infopath form by calling this.Submit() method from my button click event handler.  According to Microsoft - Note: You can write a custom submit event handler for the Submit event, and then you can programmatically call the event handler by using the Submit method. This type or member can be accessed from code running in forms opened in Microsoft Office InfoPath 2007 or in a Web browser. Its not working for me and throws this exception  - XmlForm.Submit cannot be called from the SubmitEventHandler. BTW - I'm able to submit same form without any problem if I don't use this "Submit()" method.  I really want to know why its behaving like this.  Looks like a BUG.  Thanks, Suhaib Khan

Problems submitting anonymous form via email.

I followd the steps here to configure an InfoPath form to be submitted anonymously. After much trial and error (I'm not a developer, and this was the first time I ever used Visua Studio), I got it working. I now want a second libary that uses pretty much the exact same form, but submits the completed form via email rather than into the document library. I made a copy of my first form template and then changed the submit connection to email. Unfortunately, when I publish this form and try to submit it, I get a error message that "there has been an error processing the form." Any ideas on what might be going on? Here is the working version that submits to the library. Here is the NOT working version.

Howto add selected item from dropdownlist to a textbox on the same form?


 I have been trying to figure out what the proper method is to be able to have a dropdownlist on the same form that holds a number of textboxes for properties. I am using a strongly typed typed view which was generated by the Visual Studio IDE so it contains textboxes for all of the properties of my strongly typed class.  The class has a few properties that can have a set of possilbe answers; I'd like to displat those possible answers in a dropdownlist and then when the user fills in the form and clicks the submit button the selected item would be transferred to the correct property. I have a solution but think there must be a better solution out there and was wondering if anyone might point me in the right direction.

So say I have a model with 3 properties, FirstName, LastName. and MaritalStatus.

If I generated a view for this then I'd get an aspx file with the following:


    <% using (Html.BeginForm()) {%>
        <%: Html.ValidationSummary(true) %>

            <div class="editor-label">
                <%: Html.LabelFor(model => model.FirstName) %>

First Form Submitting to second form action


I have a site master page which has 2 forms on it like so

Html.RenderAction("Action", "Controller")
Html.RenderAction("Action2", "Controller")

in each form there is a submit button as follows

<%  Using Html.BeginForm()%>
<%= Html.TextBoxFor(Function(model) model.Parameter)%>
<input type="submit" value="" name="submit" id="submit" />
<%  End Using%>

But when I click the submit button in the second form on the page it submits the values from the first form to my controller and will run both controller actions. What I want is each form to submit only its own data is there some special way to do this?

Accessing the selected value of a dropdownlist control in a Form View


I need to verify the selection in a dropdown list control is not a certain value.  It is in the edit mode of a formview.

just to verify that I could access it I tried to put the value in a label,  however it is always empty:


this is what I used

  'Dim droplist5 As DropDownList = DirectCast(FormView1.Row.FindControl("DropDownList5"), DropDownList)


            LabelHeaderwarning.Text = droplist5.SelectedValue.ToString


I also tried the validation controls but they don't seem to work with a drop down control.


Any suggestions on this would be extremely helpful



Person picker value is not displayed in email when submitting form to email

I've created an InfoPath 2010 form to use in SharePoint 2010. When the user clicks the submit form button the current view of the form is being send to an email address. It works well except for person/group pickers. Those values come out blank in the email. I've gone through the HTML and the value from the pickers are not in the HTML at all. Do have to do something extra to have the values from the pickers in my email? 

Error submitting InfoPath Web Form

I recieve a message "The form cannot be submitted because of an error" when submitting to a SP Doc Lib.  Design Checker doesn't register any errors.  I have checked the form and don't see anything that would cause the error.  I have also compared the DL columns with the form to ensure they match.  Not sure how to check on the server for this error....

InfoPath form not displaying after submitting


I created a new InfoPath form and published it to my Team SharePoint site, allowing InfoPath to create the form library.  The issue I am having is when I submit a "New Document" the completed item does not display on the site after I click submit.  The only way I can tell the item is there is to go to "View All site Content" and there I can see a count of how many examples I have submitted.  I am not sure why the submitted items will not show.  Any  guidance in resolving this issue would be greatly appreciated.


InfoPath form Submitting Issue



I am having prob while submitting the infopath form in the form lib.

1. Actually i ve published 3 infopath form in a single form lib.All forms are full trusted and all fields on each form are same.Problem is that if the form lib is empty then form successfully submit in the form lib but if there is any from available in the form lib then it doest not submit, shwoing error " An error occured while the form was being submited". And then i tried to submit from the form design preview level then it says ".....The form cannot be submitted to the following location: http://server/site/formLib/10001_6644000_2010-11-09T15_18_44_69.xml. Folder doest not exist."

2. Then i deleted all content type from the from lib settings. Then i did open the infopath form in design mode and submited at preview level then it was successfully submited to that form lib(eithere form lib is empty or not empty).

3. Above whole process i ve successfully completed in development server but in the production server i m facing this type of problem. i am unable to find out the solution. even i ve deleted the form lib and then i ve recreated again. Pls help me.

Thanks in Advance.

Regards- Sharad

InfoPath Form Save Option before Submitting the data


I want to have a save option for user to save the inforpath form, so that later they can submit the form instead of directly submitting the form. How do I provide this feature?


Error submitting form with anonymous access because of workflow


Hi All,

I’m running MOSS 2007, not using InfoPath.

I have a list set up to accept registrants for upcoming events. A customized form was attached to the list to collect sign-up information. The registrants may be authenticated users or people outside of the organization, so I enabled anonymous access for the list, with permissions to Add Items. Once the form is submitted, users are directed to a Thank You page. Two workflows were also added: the first to send an e-mail saying "thank you for registration"; the second, an Approval workflow to approve or reject registrants and send a follow-up e-mail regarding their status.

When the input form is submitted, the process works fine for authenticated users. The data for anonymous users populates the list as expected, but an Error page is generated: "The data source control failed to execute the insert command."  Through research, I've since learned that workflows cannot be initiated by anonymous users. I changed both workflows to start manually, and when that didn't work, I turned them both off completely, but the problem persists.

I've read about impersonation, RunWithElevatedPrivileges, event handlers and automatically signing in anonymous users as a Guest. But I don't have access to the servers and I'm not a programmer, so I need an easier solut

Submitting ASPX form does not work until i restart the server


I have a ASPX form that when submitted does an update to a table on MS SQL Server.  This works fine 99% of the time.  Sometimes it times out and I cannot submit that form from that computer until I restart the server.  I can go to other forms and submit which does pretty much the same thing but updates other tables.  When I go back to the trouble form and try again it still times out.  I then remoted to another location to try from there and it worked fine with exactly the same data.  Came back to problem computer/form and still no go.  I tried another browser on the same computer and no go there as well.  I also tried updating another record in the same table and still got the problem.

So it seems that once the problem starts, it seems to lock any updates from just that computer and to that table.  Weird!!!

I have tried recycling the Application Pool, restarting IIS, SQL Server and the Firewall (both server and local) but the only way to fix it is to restart the server.

Your help would be very much appreciated.




jQuery: Styling DropDownList Alternating Items (Rows)

In the following example, I will show how you can style any asp:dropdownlist very easily.

The example demonstrates how you can change alternating row items background color, using the fadeTo() to add a nice touch in the dropdownlist. You can change alt rows with a couple lines.

Working with DropDownList and ListBox Controls in ASP.NET

"In my application i am using dropdownlist to display all categories from a table. When the user clicks this control I display all records in that category. Category table also contains column called color.

I wanted display some categories in dropdown list different color and others in different color using ASP.NET."-Anonymous

ASP.NET DropDownList Web Control, Part 1

Anybody with much experience in ASP has written an include file function for populating the contents of a SELECT dropdown list with entries from a database. Some of the more advanced users have even gone so far as to add caching to their function to reduce database hits for these rarely changing menu options. Naturally, these same techniques are going to be used with ASP.NET, but with a new programming object model. ASP.NET provides a web control, the DropDownList, which can be used for the same purposes as our custom built SELECT tag from Classic ASP.
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