I’ve got a TextBox on my page that has an AJAX TextBoxWaterMarkExtender hooked up to it. I need to change the watermark text depending on a selection in another section of the page (which causes a partial page postback). Here’s the code I have so far:
if (myConditionIsTrue)
{
lblShipToHeader.InnerText = string.Format("{0} Name:", AnimalTypeName);
wmAccountName.WatermarkText = string.Format("New {0}", AnimalTypeName);
}
else
{
lblShipToHeader.InnerText = "Ship To:";
wmAccountName.WatermarkText = "New";
}
Unfortunately, this doesn’t seem to be working. On the initial page load, myCondition will be false; setting the WaterMarkText to “New”. However, once I make a selection, the watermark text doesn’t change.
The section of the page that this lives on is getting updated, as I can see the changes to lblShipToHeader.
Any suggestions on how I can get this to work?
OK, so maybe I should debug a bit more before I post, but I found the answer.
When the page posts back, my TextBox.Text property is set to the watermark text. So, since the TextBox.Text is not null or empty; the watermark isn’t displayed.
Simply adding this right before the snippet of code posted above fixed the problem: