Does anyone know of an application that I could use for Beta testing web page forms. I am looking for something that I could click a button and it will populate all the data fields with generic information. The purpose is to test a website I build to see if any errors occur by running the application and having it just fill in random information in page form with different info, symbols and characters.
You can populate the form fields using this method...
First set some values, for example...
strFirstname = "Jeff" 'temporary fill
strLastname = "Black"
Then add the value to your form field...
<input type="text" name="Firstname" value="<%= strFirstname">">
<input type="text" name="Lastname" value="<%= strLastname">">
Now you only need to click your submit button.
When you are ready to go live, simply uncomment the temporary fill values. Then they are always there for future debugging by uncommenting them.
To see at a glance the results on the next page I use something like:
response.write("Firstname = " & request("Firstname") & "<BR>"
You can use jQuery, which is a Javascript add-on (client side).
If you want to target all input fields, you can do something like this...
$("form input").val(this.attr("name"));
Running this jQuery code would populate all the input fields with the value in the Name attribute.
So the address field would populate as address, but you can change the this.attr("name") to anything else and it will populate all the fields accordingly.
Not sure if this helps, but I would think this is the fastest way to populate all the input fields. Take a look at jQuery http://www.jquery.com , I'm sure you'll find it helpful in your future in application development.
Related
Suppose you have an mvc razor webpage in which the user can approve or reject a request of some sorts but he would also have to include a reason.
Now, you could have 2 input fields: the first is to specify a reason for approving the request; the second is to specify a reason for rejecting the request. In this case all will be fine and dandy.
What if you, as a UI designer, thought that just one field for specifying the reason would be enough? In this case you would have two submit buttons or inputs (one for approving and one for rejecting) and in order to post to the appropriate controller you would have to have 2 forms for each of those submit buttons but you cannot share the 'reason' input field between the 2 forms.
So what would be the best practice for such a scenario?
PS: I know there are solutions to this: using ajax or other javascript to perform the post, defining and using attributes to pair controllers with their respective buttons, using the formaction html 5 attribute and perhaps other solutions I missed but they either seem gimmicky or have certain downsides.
Why do you need two forms? You can simply do something like the following:
<form action="" method="post">
<textarea name="reason"></textarea>
<button type="submit" name="approve" value="true">Approve</button>
<button type="submit" name="approve" value="false">Reject</button>
</form>
The buttons then operate similarly to a radio. Whichever one the user clicks, that is the value that will be posted. Then, you can simply branch on that boolean and either approve or reject accordingly.
This question is more about asking suggestions over a scenario.
I have assigned a project built with MVC .NET. There are 100s of hidden fields on _Layout.cshtml page. These all hidden fields have url stored in them.
That means they all are loaded every time layout renders.
I want to optimize this situation by removing all hidden fields from layout.
To do this I am thinking of maintaining a local .JSON file which will have objectName same as id of hidden fields'.
So if a hidden field is -
<input type="hidden" id="myId" value="www.google.com"/>
Then .json goes to -
{
"myId":"www.google.com"
}
So It would be easy for me to access its value.
Is there anyway better I can do this?
instead why dont you create a singleton class and save them in that as a list and then whenever you need in view al you need is to just parse it to local javascript variable by #html.Raw(YOUSCingletonClass) and you will get all the values
I am updating our site that is used for our people to enter in orders. The first page gathers the customer information. The user currently clicks on a button that brings them to a secondary page where they can enter part of the customers name and it will return the correct customer code. The site is written in asp using sql.
I am trying, with html5, css and asp, to redesign the form so when the user clicks on the button, they will get a modal form where they can enter in part of the customers name. It would then return the id number and put it on the main page and close the modal form or it would return a not found error.
I have the asp code but where I am having an issue is how to load up the modal form. I can show a modal form from a page - but how should I handle the validation? The form itself is basically written in the html 5 page.
Thank you for your input.
George
If you are using jQuery then this is already supported. Each form element can have required to validate against empty input fields.
You can go further with changing the type attribute. For example this one requires email addresses:
<input type="email" required placeholder="Enter your email address" value="" />
I am slowly, piece by piece learning what I am doing with ASP.NET
I've created the beginnings of my new web application, but I am often coming up against the issue that ASP.NET renames elements IDs or in the case of form fields, their names.
I have a form which is basically a sales system. It is essentially made up of two User Controls, one is a form for Customer Details (name, address etc) and the second is a form for the customer's purchases, it consists of a number lines dynamically created by Javascript created as you list the items the customer is purchasing.
Both these sections are User Controls because they are to be used for other areas of the system where this data will need to be recalled/re-entered.
When the USer Control is loaded, the field which contains the Customers' Name is renamed "m$mainContent$customerForm$name" I understand where this comes from, "m" is the ID of my Master Page, "mainContent" is the main Content Placeholder and "customerForm" is the name of the User Control.
In fact, in my case, this will always remain the same on all forms, so it is relative easy to overcome... but... suppose it wasn't
I can see there are ways I could deal with this with Javascript, but the form doesn't need an AJAX submit, a normal Post will do fine for this, so when I open up the recieving page I want to call Request.Form("name")% to save the customer's name into the database, but of course I really need Request.Form("m$mainContent$customerForm$name")%
How would I dynamically extract those prefixes from the posting form to ensure that if I rename anything or use it in a different scenario, the problem will not break it?
I am using .NET 2.0, so can't use Static Client.
This is really old but let's see if it's useful for you.
Getting this example I managed to get the value from a given field name without prefix.
I'm sure it is not the best solution, but it was useful for me. Let's say you want to recover the value of a field named "hfIdAviso", that comes in the POST as "ctl00$body$hfIdAviso":
var value = Request.Form.Cast<string>()
.Where(key => key.EndsWith("hfIdAviso"))
.ToDictionary(key => key, key => Request.Form[key])
.Values.FirstOrDefault();
That will return the value for that field.
Hope it helps.
If you include runat="server" in the declaration of your user control in the ASPX page, then you can access this control by just using the ID value of the control.
For example
In the ASPX:
<uc:MyUserControl ID="mycontrol1" runat="server" />
In the code behind (in C# syntax):
object foobar = mycontrol1.SelectedValue;
suppose you have a form inside user control that has a TextBox field with ID="txtfname".You have registered your user control in page1 and you want to POST form data to page2 :
in page1 you have user control:
<My:WebUserControl1 ID="myuc" runat="server" />
in page2 codebehind , you can get the value of user control form field (txtfname) this way :
string firstName = Request.Form["myuc$txtfname"];
Hai guys,
I had this doubt for a long time now. Now being a part of stackoverflow i ve decided to ask it... Consider form without Runat="server" and it contains two html text boxes and a html button all without Runat="server", now my is it possible to submit this form and i have to insert the values in my DB...
If your "HTML button" is a <input type="submit" /> element, clicking it will indeed cause the <form> to be posted. However, it will not raise any Click events, since there is no Button object associated with the HTML button you have clicked.
In your Page_Load() method (or similar) you will be able to retrieve the posted values using the Request.Form collection. Example with text input has name="myField":
string postedVal = Request.Form["myField"];
Yes. You can read the values from those controls by using
var valueFromHtmlControl = Request.Form["Control-Identified"]
Absolutely - this can lead to some unwanted effects, such as cross site request forgery, which is worth looking out for:
Wikipedia ref