Google App Maker: TextBox only accept Numbers - google-app-maker

How to set a TextBox to only accept Numbers?

The easy way is to bind it to Model's field of Number type. In this case App Maker will take care about the user's input validation (on some extent).
If you want to have more control then you can script your custom validation rules in the textbox's onValidate event and play with its configuration in the Data Validation properties section.
If you want to explicitly forbid user to enter everything but numbers, then you'll need to go down the native JS way and handle keyboard events or any other approach mentioned here: HTML text input allows only numeric input. You can hack into in onAttach event of the textbox widget. To get widget's DOM element you can use this code: widget.getElement().

If it has a model table associated with the field you can restrict the input value based on a regular expression.
The regex would be
[0-9]+
or
\d+

Related

What is a property and a control in Pega 7.2?

I want to know the difference between controls and properties in PEGA 7.2.
Property is like a variable in Java -
https://pdn.pega.com/sites/pdn.pega.com/files/help_v72/procomhelpmain.htm#rule-/rule-obj-/rule-obj-property/main.htm?Highlight=properties
Controls are used in pega to define how properties appear on UI -
https://pdn.pega.com/sites/pdn.pega.com/files/help_v72/procomhelpmain.htm#rule-/rule-html-/rule-html-property/main.htm
PDN is best source for all pega related definitions
Property is a Data field in general. You can imagine a variable in C or Java. That can be primitive type or complex type. In Pega, property type may be Single or Page, Page List, Object...etc.
Control is a UI component like textbox, button, checkbox, link...etc.
A property can be associated with a control to display in certain format on a user screen.
I would define a property 'CustomerName' and my control to read Customer name is 'TextBox'.
A property stores some value. It is like a box.
Control is a user interface element, which helps your system to get a value from or show it to a customer.
Always, properties and control are used together.
For example, a user fulfills a UI control with theirs name. And the name is assigned to some property.

View state vs Hidden field in asp.net

How can we take decision for viewstate and hidden field in ASP.NET.
In my case i am using page cross post back and by using public properties of first page i am accessing them in second aspx page.
After getting public variable in second aspx page i need to access those value in second page but as soon as i do postback in second page, i am not able to find those value.
Hence to solve this issue i have two solution either use viewstate in second page or using hidden field in second page.
I am not able to decide which one should i use?
The approach is quite the same. Only difference should be the size of stored info (viewstate is using [sometimes encrypted] base64 while hidden fields use plain text unless you encode them yourself), and viewstate allows you to make sure the data was not tampered with thanks to the default validation it has in place.
If the data is small and you want to manipulate the value based on some client-side behaviour, hidden field will be useful.
Difference between view state and a hidden field in asp.net
http://royalarun.blogspot.in/2012/03/difference-between-view-state-and.html
Both are used to store the value during the postback in asp.net , but
In View state - not able to change the value by Client side code i.e java script.
Hidden field - possible to change value by Client side code.
In View state - You can store more than one value like Datatable and Dataset
Hidden field - You can store more than one value in hidden field,by serialized it.
View state data is encrypted and Hidden field is not encrypted

Conditional popup box in vb.net & asp.net

I'm working on a piece of code at the moment that allows the user to enter values into fields. Once the user clicks on the 'save' button I am checking those fields against certain conditions (essentially calling a bunch of stored procedures to assess the values). If any of these 'rules' are met, I need to generate a popup that informs the user that certain values need to be fixed before they can continue for some of the conditions, and for others just to inform them of what conditions may need their attention.
The main thing I need help with is, how do I generate a popup box in my codebehind if the conditions are met?
While not a true popup, one option would be to use a CustomValidator to accomplish this along with the AJAX ModalPopupExtender. Server side you can do whatever you need to test validation rules and display a message to the user. I personally would prefer this over a popup window.
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx
The following article hits on this in more depth:
http://ashishware.com/ASPValid.shtml

Legacy ASP.NET 1.1 with jQuery integration problem

I am working on a legacy web application written in VB.NET for ASP.NET 1.1. One particular page has a form with a number of fields. In response to a drop-down box changing value, I am clearing a number of fields, resetting a number of drop-down boxes to the first option, and setting them all to "disabled" in the UI. To do this, I'm using jQuery. I add a CSS class to all of these fields, and then my jQuery selector is something like the following: $("*.my-css-class"). Here's some sample code to explain.
var fields = $("*.fields");
if (some_condition) {
fields.val("");
fields.attr("selectedIndex", 0);
fields.attr("disabled", "disabled");
}
The UI updates as expected in response to the above js code, but when I post back the page in response to a button click, the original values still persist on the server-side related to these controls. For instance, txtSomething is one of the fields with a CSS class "fields" (so it will get selected by the above jQuery selector). The user types "1234" in this text box and submits the form. Either the same page is posted back to itself retaining its values, or I return to this page and prepopulate the values on the server-side (for example, the user clicks an Edit button on a summary page), so the control txtSomething is initialized on the client with the value "1234". My jQuery code clears the value as far as the user sees it in the UI, and then the user clicks a submit button. If I interrogate the value with a jQuery selector, the value of this field is an empty string. When the page is posted back and I'm stepping through the code (or doing something with the value of this control), it is still "1234".
A very important point to make is that these values are sent back to the browser after being submitted once. So, picture a form being submitted, or any case where these values are bound or set on the server-side and outputted to the browser pre-populated (as opposed to being output to the browser with default or empty values). If I load the page as default (empty text boxes), enter some text, and then trigger the js function to clear these fields, the value I typed never makes it to the server.
why do you need to disable those fields? Disabling controls can make them not post values to the server ... at least that is what happens when an asp.net control is disabled server side.
Update 1: couldn't take having the doubt if it was only server side, so I looked it up :) http://www.w3.org/TR/html401/interact/forms.html#h-17.12.1 ... "In this example, the INPUT element is disabled. Therefore, it cannot receive user input nor will its value be submitted with the form.", so I was right, even when disabling it client side it won't post the value

In ASP.net Webforms how do you detect which Textbox someone pressed enter?

In ASP.net Webforms how do you detect which Textbox someone pressed enter?
Please no Javascript answers.
I need to handle it all in the code behind using VB.NET.
Why do you need to determine the which TextBox was pressed? Are you looking to see which TextBox was being focused so that you can trigger the proper button click event?
If you are looking to do something like this, one trick I've done was to "group" the appropriate form elements within their own panel and then set the "DefaultButton" property accordingly.
Doing this allows me to have a "Search by Name", "Search by Department", "Search by Id", etc. Textbox/Button combination on a single form and still allow the user to type their query parameter, hit Enter, and have the proper search method get invoked in the code behind.
I suspect it cannot be done without javascript - when you hit enter, the browser submits the form - it doesn't submit what field had the focus. So unless you use JS to add that information to the form being submitted, you're out of luck.
Without using Javascript, you just can't. That information is not conveyed from the client browser to the server.
As far as I know there is no possible way for a server side script to detect that. It simply does not get sent to the server. It must be done client-side (i.e. With Javascript) and then sent to the server.
I solved this for one site's search by looking at the Request.Form object, server side to see if the search box had a value. I did it in a base class that all my pages (or a base class for the masterpage) inherit from. If it has a value, the odds are pretty good somebody typed something in and hit enter and so I handled the search.
In the event handler, the "source" object (the first parameter of the event handler) is the object raising the event. Type it to button and get the name, or use reflection to get information out of the non-typed object.
In addition, if the control is a child of a web control that you do not have raise its own events (just saying...) then you can use OnBubbleEvent to determine what's going on. OnBubbleEvent also has a "source" parameter you can type, or use reflection on.

Resources