Asp.net textbox shows text and value differently - asp.net

I am populating the value of a text box using javascript document getElementById.
I am able to see the text change in UI. However in code behind it shows a different value. I did inspect element on the input and saw the value and text are showing differently. How is this possible.
This is what I see on inspect element Value = '19 Bradston Street (South Bay)' but the UI shows ' 35-49 East Santa Clara Street' :-
<input name="ctl00$ContentPlaceHolder1$CtlPropertySales$txtBuildingName" type="text" value=" 19 Bradston Street (South Bay)" id="ctl00_ContentPlaceHolder1_CtlPropertySales_txtBuildingName" tabindex="95" style="font-family:tahoma,verdana;font-size:11px;font-weight:normal;height:16px;width:150px;">
This is the Javascript code that is setting the value:-
document.getElementById('<%=CtlPropertySales.FindControl("txtBuildingName").ClientID%>').value = params[1]
Can any one tell me how this is possible and how I can solve this.

It looks like you might not be getting the ID properly. You're looking for
<%=CtlPropertySales.FindControl("txtBuildingName").ClientID%>
but what is the ID for CtlPropertySales? Try getting the ClientID of CtlPropertySales first, then get the ClientID of txtBuildingName.
Or just
document.getElementById('<%=ctl00_ContentPlaceHolder1_CtlPropertySales_txtBuildingName.ClientID%>').value= params[1]
You might consider add this to your web.config:
<system.web>
<pages clientIDMode="Static">
</system.web>
With clientIDMode="Static", IDs will retain their original name and you will not need to use ctl00 or ClientID any more. That should help with setting values, but it will affect all the IDs in the app/site and you'll have to update scripts.

Related

Request.Form without Values

i have a problem
I have an A form with one with a hidden field that redirects to the other in a button.
In form B, i mus get the value of this hidden field by POST.
But when I do the Request.Form("Hidden_Field"), it only brings me the name of the field, when what I need is the VALUE.
any ideas?.
here is the code:
Form A:
<asp:HiddenField ID="SIGNSYS_OUTPUT" runat="server" Value="123" />
Server.Transfer("~/VerifyAccountBGBAResult.aspx", True)
Form B:
Me.Value = Request.Form("SIGNSYS_OUTPUT")
This Request returns me in the value "SIGNSYS_OUTPUT".
Server.Transfer does not transfer the information unless the form got posted first, I'll assume this is the case.
Request.Form gets the information based on the name of the control, example.
<input type="hidden" name="SIGNSYS_OUTPUT" value = "123" />
When you use runat="server" the name is generated by .net. You'll need to do a viewsource to get the proper name. It might end up being something like this.
Request.Form("ctl00$ContentPlaceHolder$SIGNSYS_OUTPUT")
In your case, I think using Server.Transfer might not be the best solution. You could look at other solution like using a session, the database, process on the page and send to result to the other page, ect..

Binding Null Placeholder not translated in view based NSTableView

I have a view based NSTableView whose content is bound to an array controller. I bind one specific text field using objectValue.title. This works fine. I also have set a null placeholder for that binding which is indeed displayed when the value is null. However, it does NOT use translated values of the null placeholder.
The identifier for the placeholder is je1-iU-XEu.ibShadowedIsNilPlaceholder and the corresponding translation is je1-iU-XEu.ibShadowedIsNilPlaceholder" = "Stationsname";.
If I do the same with a cell based table view, it works. Any idea why this is not working?
I'm having this bug today. Seems that Apple didn't care about fixing it.
If you use localized strings, then you might have to dive in the storyboard code and ensure the object ids are matching.
In your storyboard, you will see an element with key "NSNullPlaceholder", wrapped into another one with id "Ds1-Gj-yzu". (See the code below)
Go to your string file and ensure you have something like
"Ds1-Gj-yzu.ibShadowedIsNilPlaceholder" = "Your translation";
WARNING: each time you will change the placeholder value in the storyboard, a new ID is generated, breaking at the same time the localization.
<connections>
<binding destination="TyA-Z9-mxH" id="Ds1-Gj-yzu" keyPath="objectValue.group" name="value">
<dictionary key="options">
<string key="NSNullPlaceholder">Group</string>
</dictionary>
</binding>
</connections>

phone number formatting in client side while entering number in flex

in my flex application i want to keep a format like...
i want to show space in client side while entering phone numbers..
After entering three numbers cursor should leave a space...
for eg:- 111 111111
is there any idea to work this in CLIENT SIDE itself
You can use Masked TextInput component. More info is here.
You should be able to work something out using the mx:PhoneFormatter (which can be customized to match whatever pattern you'd like): http://livedocs.adobe.com/flex/3/html/help.html?content=formatters_2.html
<mx:PhoneFormatter formatString="### ######" />
Perhaps replace the contents of the input field with the PhoneFormatted version onKeyUp.

Input type "hidden" vs text area

I'm having a weird issue with an input type hidden and was wondering if anyone has ever seen something like this before. I'm saving about 2MB of data to a hidden field, in a comma separated format, then I'm posting that data to a jsp that simply sets some headers (so the output is recognized as an excel file) and then echoes the data.
I'm seeing that the variable that holds this data gets empty to the jsp side, even though I see that it's getting posted to the server (I'm seeing it with an HTTP sniffer) and all data seems to be contained correctly in the hidden field (I'm seeing that with firebug). However, if I change the object type to be a text area, the data is received correctly on the server's side.
Another weird thing I'm observing is that if I use URL encoding on the data, even using a text area, nothing gets to the server. If I don't use URL encoding but I have the hidden field, nothing gets saved to the field (it's empty when I check it with firebug). I don't understand that either...
I'm wondering if there is any special security setting that prevents the hidden fields to post big amounts of data to a Tomcat web server. Does anybody know anything about that?
If it makes any difference, I'm using the default enctype on the form (application/x-www-form-urlencoded)
I'm currently using a text are and setting the style to visibility "hidden" but it bothers me not to understand what's going on *sigh... Any suggestion is appreciated
I think having 2MB of data in a hidden field is a mistake regardless. You should store that kind of thing on the server as part of the session state, not send it back and forth between the server and the user, as you are doing. Instead, use a hidden field or cookie for the session variable*, which will be used to look up the 2MB of data.
*Don't do this by hand. JSP already has support for session state, among other things.
The server can't tell the difference between a textarea and textbox. All form elements are simply posted as name/value pairs.
Most likely, you have a double-quote somewhere in your data that's terminating the value attribute of the hidden input element. For example:
<input type="hidden" value="Double " quote" />
You need to escape the double-quotes by replacing them with "
<input type="hidden" value="Double " quote" />

How to extract element id attribute values from HTML

I am trying to work out the overhead of the ASP.NET auto-naming of server controls. I have a page which contains 7,000 lines of HTML rendered from hundreds of nested ASP.NET controls, many of which have id / name attributes that are hundreds of characters in length.
What I would ideally like is something that would extract every HTML attribute value that begins with "ctl00" into a list. The regex Find function in Notepad++ would be perfect, if only I knew what the regex should be?
As an example, if the HTML is:
<input name="ctl00$Header$Search$Keywords" type="text" maxlength="50" class="search" />
I would like the output to be something like:
name="ctl00$Header$Search$Keywords"
A more advanced search might include the element name as well (e.g. control type):
input|name="ctl00$Header$Search$Keywords"
In order to cope with both Id and Name attributes I will simply rerun the search looking for Id instead of Name (i.e. I don't need something that will search for both at the same time).
The final output will be an excel report that lists the number of server controls on the page, and the length of the name of each, possibly sorted by control type.
Quick and dirty:
Search for
\w+\s*=\s*"ctl00[^"]*"
This will match any text that looks like an attribute, e.g. name="ctl00test" or attr = "ctl00longer text". It will not check whether this really occurs within an HTML tag - that's a little more difficult to do and perhaps unnecessary? It will also not check for escaped quotes within the tag's name. As usual with regexes, the complexity required depends on what exactly you want to match and what your input looks like...
"7000"? "Hundreds"? Dear god.
Since you're just looking at source in a text editor, try this... /(id|name)="ct[^"]*"/
Answering my own question, the easiest way to do this is to use BeautifulSoup, the 'dirty HTML' Python parser whose tagline is:
"You didn't write that awful page. You're just trying to get some data out of it. Right now, you don't really care what HTML is supposed to look like. Neither does this parser."
It works, and it's available from here - http://crummy.com/software/BeautifulSoup
I suggest xpath, as in this question

Resources