I need to validate that a user makes a selection from a select list OR they enter text into a textbox. I'm trying to figure out which validator to use. Is there a way to make a CompareValidator do this? Or would I need to write a custom validator? If custom, do I write one for each of the form elements, or does the validation happen upon submit?
HOW TO Force C#/ASP.NET to not rename input elements to work consistantly with Form.GetValues.
ASP.NET changes the "name" property of input elements set with "runat=server" to match their ID property at run time. This causes server-side calls to HttpRequest_Page.Form.GetValues to now be able to get the expected Form element.
I do not want ASP.NET doing this. I do not want to change the naming convention of my id properties either. In fact, I need the ID to be different than the name, as I use client side script to change/create/delete controls on the fly.
I have downloaded the source code for the latest version of the AjaxControlToolkit and have noticed that there are differences in the scripts included in the solution.
So I am new to ASP.NET MVC and I would like to create a view with a text box for each item in a collection. How do I do this, and how do I capture the information when it POSTs back? I have used forms and form elements to build static forms for a model, but never dynamically generated form elements based on a variable size collection.
I want to do something like this in mvc 3:
How do I do a text box for each guest? And how do I capture them in the action method that it posts back to?
Currently, I have a list of PhoneNumber objects that I display. Here's an example of the output of the view:
Notice the naming of these elements: name="existing_phone[labels]", name="existing_phone[numbers], name="new_phone[labels]", name="new_phone[numbers].Back in the Classic ASP days, I recall being able to do something along the lines of:
And that would give me a 2d array of phone numbers to work with. This doesn't seem to work in .NET. Has anyone tried to do something similar that can point me in the right direction?For new phones, I should simply be able to iterate through each item and insert into the database. For existing phones, I should be able to update (or delete if the label or number are blank) records based off of the id number supplied in the array.OR..if anyone has a better, alternate solution, I'm open to something else.
When I select the items that have been added and it does a postback I get the following error:
Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
I have a form with a bunch of labels and images on it. Is there a way I can capture parts of that form into an images file (jpg/bmp, etc)? Ideally I could specify the x-y coordinates, and save that to a jpg.
As you know froms could lead to accessbility issues and unlike PHP when I was dealing with it, everything in ASP.NET we can say is wrapped inside a form. As you know not every elements is a form element and from accessbility point of view the screen readers have what is called 'forms mode' which only interact with form elements. Can anyone calrify why is that in ASP.NET?
I have a form with certain elements, input boxes, check boxes etc. I need to encrypt the names of these input boxes and check boxes. I'm currently using a Rijndael encryption/decryption method through c# however this is making the encrypted names too long to be passed in a post. Is there a better way to get decent encrypted names? my purpose is to have the names encrypted before the post happens so if someone views the code behind the names are already encrypted.
Is it possible to populate all generated form elements using AutoCompleteExtender? Now i have one textbox called Userid when i put some number it is listing the list of IDs from the database using AutoCompleteExtender. I need to make, if selected ID correct, other Form Field should fill with relevant data. Currently i am filling it with TextChange event for the UserID field, but it is reloading the whole page. So Is there anyway can be filled all Form Elements using AutoCompleteExtender?
I am working on some ASP.NET web forms which involves some dynamic generation, and I need to add some onClick helpers on the client side. I have a basic outline of something working, except for one huge problem.
There are multiple HTML tables, each generated by a different ASP.NET web control. Each table can contain overlapping field names, which is causing a problem with my JQuery click event handlers. The click event handler is linking to unintended form fields in addition to the intended form field.
I have provided a simplified sample version of the code below. This code is trying to set the value of textbox box1 when a particular radiobutton is selected in the table with id=thing1. Obviously, the jquery code will be triggered for the form fields in both tables.
The tables are dynamically added to the webpage based upon different conditions. It is possible that no tables will be loaded, only 1 table, or both tables might load. In the future, other tables could be added. Each table comes from a different .net web control.
Other than renaming the form fields to make sure they are unique across all user controls, is there a way to have JQuery act only on the intended form fields? In other words, could the table ID be incorporated into the JQuery code in a manner that does not become a nightmare to maintain later?
I'm building a shopping cart page that could potentially contain dozens of separate items. Each item has a collapsible panel that contains several form elements that can be used to customize it. Most of the cart is wrapped in an UpdatePanel so that I can avoid a full postback when the user makes changes. When there are many items in the cart, there are of course many many postback elements, all of which are included in the raw form post, even though each post is really only triggered by the change of a single element
I have this code in the <script runat="server"> section of the second web form:
I've tried a few things that work, but none of them seem perfect so I wanted to see what the community had to offer. Also, I'm not looking for suggestions that avoid dynamic DOM elements (like use a Wizard, etc.). I'm specifically trying to improve my technique with dynamically created DOM elements.