Sometimes I do despair when working with ASP.Net - another problem that shouldn't be!
On the web form there is an ASP table. In the ASP table there is a user control which I am making some changes to. In the ASP table there is a text box....nothing out of the ordinary so far!
In the code behind, as part of the Page_Load, I need to access the ClientID of the textbox in order to register some javascript...so I do and the javascript seems to do everything it needs to. Everyone's happy.
No, no apparently everyone's not happy, ASP.Net itself is very unhappy!
On accessing the ClientID, the id that appears in the source is:
myControl_myTextBox
commenting out the line that accesses the ClientID means the id is rendered as:
ctl00_BodyPlaceHolder_myControl_myTextBox
The line that accesses the ClientID looks like this:
jsBuilder.AppendFormat(@"var filter = new TBFilter($(""#{0}"")[0]);", myTextBox.ClientID);
This in itself does not bother me, but the fact that it breaks the postback, does! If you type something into that textbox and hit the submit button (there's a submit button on the page!), it reloads the page, but puts the default value back in the textbox and completely ignores what you originally had. Madness - I haven't done anything particularly weird and out of the ordinary, so why has it broken the postback?