I was dynamically changing sitemaps in Asp.Net 2.0 using c#.
I wanted to remove a node in the site map chain under certain conditions.
You would think this could be done by removing the errant node (1) from its parent node (2) and then adding in the node that you want (3) instead. However this doesn't work, you also need to set parentnode of (3) to (2).
Then its all tickety boo.
Monday, December 10, 2007
Thursday, September 20, 2007
ASP.Net Ajax Update Panel changes TextBox Width
I had an UpdatePanel inside a table.
The table width was set to 100%.
The TextBox width was set to 90%.
On a button click the text of the TextBox was changed. The page updates asynchronously as hoped but the text box width changed to be larger than the page width. I have read some forum posts and it seems that it is not possible to stop this for some reason.
Instead of setting the width of the TextBox we can set the Columns attribute instead. This is obviously not as good and will cause problems with differing font sizes but is better than any other alternative I have found.
I assume that this is a bug in the Ajax implementation, or possibly within the browser.
The table width was set to 100%.
The TextBox width was set to 90%.
On a button click the text of the TextBox was changed. The page updates asynchronously as hoped but the text box width changed to be larger than the page width. I have read some forum posts and it seems that it is not possible to stop this for some reason.
Instead of setting the width of the TextBox we can set the Columns attribute instead. This is obviously not as good and will cause problems with differing font sizes but is better than any other alternative I have found.
I assume that this is a bug in the Ajax implementation, or possibly within the browser.
Wednesday, September 12, 2007
ASP.NET Session State Variables NULL is the same as 0 for an integer
I set a session variable to Integer 0 and then tried to read it back in to an integer.
The result was a NULL value.
Writing the value as a string and then converting it when reading it back in solved the problem. I assume that 0 is the default initial value for an integer and so ASP did not bother to save it, although I haven't checked this. This would mean that other types would have the same problem.
The result was a NULL value.
Writing the value as a string and then converting it when reading it back in solved the problem. I assume that 0 is the default initial value for an integer and so ASP did not bother to save it, although I haven't checked this. This would mean that other types would have the same problem.
Wednesday, June 6, 2007
Delphi VCL.NET Scroll TextBox whilst updating
The scenario is a long process which logs out progress to a textbox. We repaint the form every iteration (or less). We also want the textbox to be showing the text at the bottom (which is the most recent). Another way would be to insert text at the start of the text box but I think this would be less intuitive for users.
The code is as follows
The textbox must have the focus in order for select to work (according to the documentation - I didn't try it).
The Select procedure moves the caret to the end of the text and scrolltocaret scroll s the box to this position.
Changing the text of the textbox will have invalidated it so calling update will repaint it.
textbox1.Focus;
textbox1.SelectionLength := 0;
textbox1.ScrollToCaret;
textbox1.ScrollToCaret;
Update();
If there are multiple such controls on the form then when each one gets the focus it becomes selected and repaints itself. If you wish to avoid this remove the selection in the "Enter" Event.
The code is as follows
The textbox must have the focus in order for select to work (according to the documentation - I didn't try it).
The Select procedure moves the caret to the end of the text and scrolltocaret scroll s the box to this position.
Changing the text of the textbox will have invalidated it so calling update will repaint it.
textbox1.Focus;
textbox1.SelectionLength := 0;
textbox1.ScrollToCaret;
textbox1.ScrollToCaret;
Update();
If there are multiple such controls on the form then when each one gets the focus it becomes selected and repaints itself. If you wish to avoid this remove the selection in the "Enter" Event.
Tuesday, March 27, 2007
Cannot connect to SQL Server 2000 from Visual Studio 2003 on local machine
I had a problem connecting to SQL Server 2000 from Visual Studio 2003.
I could connect with Query Analyser, Enterprise Manager and Visual Web Developer 2005 Express.
I tried lots of combinations of (local), localhost and mymachinename based on previous experience but nothing worked. I also restarted the server to no effect.
The error returned was "sql server does not exist or access denied", which was standard microsoft horseshit.
When running from Visual studio trap the mysqlconnection.open() statement in a try catch statement to get this error message, otherwise you get a much less useful and more generic message along the lines of "System Error".
In the end I fiddled with the Server properties and set the "Audit level" from "None" to "All" and unticked "Allow other servers to connect remotely .... using rpc". The server reset and everything started working.
No idea why.
This link is also helpful with some bakground on the (local), localhost, mymachinename type issues.
change (local) to localhost and what's the difference
I could connect with Query Analyser, Enterprise Manager and Visual Web Developer 2005 Express.
I tried lots of combinations of (local), localhost and mymachinename based on previous experience but nothing worked. I also restarted the server to no effect.
The error returned was "sql server does not exist or access denied", which was standard microsoft horseshit.
When running from Visual studio trap the mysqlconnection.open() statement in a try catch statement to get this error message, otherwise you get a much less useful and more generic message along the lines of "System Error".
In the end I fiddled with the Server properties and set the "Audit level" from "None" to "All" and unticked "Allow other servers to connect remotely .... using rpc". The server reset and everything started working.
No idea why.
This link is also helpful with some bakground on the (local), localhost, mymachinename type issues.
change (local) to localhost and what's the difference
Subscribe to:
Posts (Atom)