Saturday, March 31, 2012

text box misbehaviour

Hi

I have a text box which provides a parameter for a query which does a search against a database. the text will be populated on load. But if I edit the text box like say add a few letters then the search is not working. So I did the search by doing the test query feature of the wizard giving the exact parameter value ,it gave me the results. So I went back again and deleted everything upto the first first letter and manually re-entered the parameter in the textbox and searched this time I got the results. Seems like there is some hidden values in the TextBox which I have to delete manually . Has anyone come across a situation like this . Please advice how to solve this behaviour.

Thanks

How are you pre populating the textbox?

<asp:TextBox id="foo" runat="server">bla bla bla </asp:TextBox>

or

<asp:TextBox id="foo" runat="server" Text="bla bla bla" />

Note how the first way leads to a phantom space in your textbox...


I am populating it from a dataRow cell.

building1TextBox.Text = BuildingAddressTable[0].BuildingAddress;

What do you think

Thanks


hmm.

What does the Text property look like if you view it in the debugger when it is assigned to your parameter collection? Do you seen any phantom characters?


maybe something like this

building1TextBox.Text = Trim(BuildingAddressTable[0].BuildingAddress);

or

building1TextBox.Text = BuildingAddressTable[0].BuildingAddress.ToString().Trim();

not sure about the syntax - could be just .Trim()

This will trim whitespace from the beginning and end of the specified string.

0 comments:

Post a Comment