|
And soon that'll double with all the hits on my new blog at http://blogs.msdn.com/heaths[^]!
Much of it is actually ASP.NET now, but not the stock "stuff". Much of it is custom page handlers. We also use SharePoint a lot, which is built on ASP.NET (well, at least SharePoint Service 2.0). There's still some ASP running around, but slowly things are being upgraded to ASP.NET. There have been some MSDN articles and MSDN TV episodes discussing these transitions if you're interested.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hey all,
I'm trying to adapt our application to work with large fonts- that is when someone goes to display properties, appearances, and changes font size to large or extra large, have my application have larger font sizes. The basic change I've made which works fine is to put in the constructor of the main application the code:
this.Font = new Font(this.Font.FontFamily, SystemInformation.MenuFont.SizeInPoints, this.Font.Style, this.Font.Unit, this.Font.GdiCharSet, this.Font.GdiVerticalFont);
SizeF sf = Form.GetAutoScaleSize (this.Font);
this.AutoScaleBaseSize = sf.ToSize ();
this.AutoScale = true;
I had some trouble just changing the fontsize, that's why I've got that more complicated call (which may not be entirely necessary). Anyway, that works. The problem is that for some reason, in some of my internal controls (but not all! that's the thing) textboxes are getting wider- stretching to the right. This is causing problems like the textboxes covering up buttons that are next to them, etc. I can't figure out for the life of me why they're getting wider- and I can't figure out why only on some controls they are. For example, on one form they're stretching as far as the panel lets them.
I thought it might be the AutoSize property, but even with that off, they still do it (the AutoSize property, as it turns out, only resizes the height based on font size). I coded something that just reverses the change, but there should just be a way to tell the textbox not to resize automatically like it is doing. I checked all over my code and there's nothing I do to change the width. In fact, when I tried to put the code to reverse the automatic change in the Layout event rather than the Resize event, it works, but then when I minimize and maximize, the textboxes stretch again, so it really does see like something built in. Does anyone have any clue as to what might be causing this and how to turn it off?
-David
|
|
|
|
|
|
Sorry, that doesn't fix it. In fact those lines are there so the window resizes appropriately. The AutoScale on the main application assumes the default font size and when that changes, you need to change the AutoScaleBaseSize. I got that from a MS developer.
The reason I'm annoyed at this is because it seems like a built-in behavior in some manner, and there really should be a way to turn it off rather than just hardcoding it in so whenever a control tries to be helpful, I reverse what it does. I'm finding this a common theme with some of these controls.
For example, in a ListView with checkboxes and FullColumnSelect, using shift-select or control-select checks boxes automatically. There's no way to turn this behavior off. I ended up having to test for a shift or control click and set a boolean value to true and then in the onCheck event reverse the check if the boolean value was true.
I think it should be a more common practice when microsoft builds in automatic "features" like this to have the option to turn them off.
-David
|
|
|
|
|
I define some of my variables in asp.net page as a static variable, to keep track of the value when do a postback. For exmaple
<br />
protected void Page_Load(Object Src, EventArgs E) {<br />
static int Counter = 0;<br />
}
The question is, will this static variable become global? mean everyone login to the page from different session see the same value?
or the value only applicable for current session?
Thanks.
regards,
vic
|
|
|
|
|
Your question would be better handled in the ASP.NET Forum. This is a web development/ASP.NET question, regardless of the language that the code-behind is written in.
The static variable idea won't work considering that ASP.NET, as any HTML page, is stateless. You have to save the values to hidden fields on the page, to be read back when the page is posted back to the server, or in the Session object, or somewhere else that can handle state. And, no, it won't become global. There is no such thing in the .NET Framework.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak,
Thanks for the info.
My static variable actually work on the page... just that I am worry it become global. Your answer make me feel better.
p/s: I post it here coz I am using C# in my asp.net. Anyway thanks for reminding me.
|
|
|
|
|
While I normally agree with Dave, I don't see this as specific to ASP.NET so I'll bite.
This won't even compile. You cannot declare fields (a static int Counter looks like a field to the compiler) inside method implementations.
If you need to declare a static variable, do so in the class (your derivative page) like so:
static int Counter = 0;
protected override void OnLoad(EventArgs e)
{
Counter++;
base.OnLoad();
} This will increment for the lifetime of the object, which is alive for as long as the AppDomain is alive in which it was created. For Windows Forms applications, this is typically as long as your application is running (your application could, however, create a new AppDomain). With ASP.NET, this is for as long as the web application doesn't need restarting (like after editing the Web.config file for the site or application; or, again, unless you created a separate AppDomain for some reason).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Heath Stewart,
Thanks for the explaination!
You are right, I actually declare the static variable outside the Page_Load method. My mistake here...
I just want to make sure that, as long as the static variable won't share by other sessions in the same server... it will be fine...
Thanks guy...
|
|
|
|
|
Statics are always within the context of an AppDomain, so if your process consists of two or more AppDomains statics will be different.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hey Heath!
How's life in the shadow of an actively rumbling volcano?
I thought he was asking if it was possible to persist a session-specific value using a static, like you've suggested. I did't think that's possible, but I could be wrong? Is the AppDomain session-scoped or application-scoped? Seems like a dumb question, I know. But just for clarification purposes...
Also, just to point out for future readers ... yeah, right! ... using a Static such as this, in either Session or Application scope, does not propogate it's value acrossed multiple servers hosting the same web application. So, if you have two or more web servers running the same application, say for load balancing purposes, all servers will have different values for the Static "global" variable.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave Kreskowiak wrote:
How's life in the shadow of an actively rumbling volcano?
Exciting! I've been through tornados having been from the midwest, but this is a new experience. I had a lot of interest in volcanoes (and earthquakes) when I was younger (did a fair share more than just "class projects" on them) so this will be fun to see in person. If I get a chance I'll be taking some pics.
It's not expected to be dangerous to the greater Puget Sound area, though, so I'm not worried.
What is exciting is that I've killed two potentially deadly spiders in our new apartment, all within a week of moving in! While they look like brown recluse spiders, 1) those are only supposed to be in the south-east, and 2) they're often mistaken for hobo spiders, which are in this area (and just as potentially deadly).
Back to the topic at hand...
As far as the problem goes, it really all comes down to AppDomains. A process can have more than one AppDomain, and a web application is an AppDomain. As long as the AppDomain is active, the statics are, well, static. Since an AppDomain cannot span multiple machines, what you said about services is true.
To the original poster, if you want a "global" variable across multiple server or applications, you either need to persist it in some storage medium (like a database, although that can be pretty slow depending on load) or use .NET Remoting which allows communication between multiple AppDomains (through indepedent transport and formatting channels). You could, for example, have a singleton running on some machine and the separate servers communicate with the remoting object through a proxy (which you implement a mutex to lock the increment and/or decrement).
There's lots of different ways to solving the problem.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Heath Stewart wrote:
Exciting! I've been through tornados having been from the midwest, but this is a new experience. I had a lot of interest in volcanoes (and earthquakes) when I was younger (did a fair share more than just "class projects" on them) so this will be fun to see in person. If I get a chance I'll be taking some pics.
Awsome! I'm so jealous! I've had that same, call it morbid, curiosity about how these things work and still have it to this day.
I've been within 500 feet of a tornado before, BUT COULDN'T SEE IT! because it was heavily rain-wrapped. All we saw, looking through the 8 foot tall plate glass windows in the front of the store , were roofs being torn off buildings ... what a let-down that was.
I've even had the pleasure of watching empty Coke cans slide back and forth acrossed my desk during earthquakes in and around South-East Michigan. I know, it's not an earthquake mecca and they're weak by Pacific Coast standards, but it's still pretty funny to try and balance on one foot while putting jeans on during an earthquake (1986 - epicenter in middle of Lake Erie).
If Mt St Helens blows again, we want pictures! LOTS of pictures! Setup a webcam if you have to! Who knows if the one at the Johnston Ridge Observatory[^] will be working if/when it does decide to erupt.
and now, back to our show...
--------8<--------------------------
I agree with your assessment of the speed of persisting Session info to an SQL server. It's as flexible a solution as your going to get, but it does tend to be a little slow. I've installed the SQL state server package that comes with, I can't remember which or where, but I think, ASP.NET or Visual Studio .NET Enterprise.
I've thought about both single and multiple server session state caching schemes. A single server solution is easy to implement, but has the downfall of not being scalable to support say, 15 IIS servers.
Mostly, I've wondered what the benefits, limitations and pitfalls are of a solution consisting of small cluster of servers, no more than 3 to start, each running a "Singleton" component, but sync'ing up their data on a real-time basis. These servers could possibly run behind a single-IP solution to facilitate fault-tolerance.
The list of ponderings I've come up with is pretty long... What would be the database synchronization requirements? What would the specification of the synchronation protocol look like? What kind of traffic load would just the synchronization protocol generate? There would probably have to be some kind of mechanism to ensure the consistancy of the state data before the next request comes in on the same session. What would happen if two requests came in on the same session, but the state servers were not able to sync up their data before the second request came in? How would the servers defend themselves against running out of memory since there would be no media to drop the database on? What would the memory requirements be? How would the servers detect a failed server? How would the synchronization protocol handle this situation? How would it handle the reintroduction of a restarted server? ... The list goes on and on...
What if we cahnged the scheme so that each server only holds a portion of the overall database instead of a full copy of it? Start a new list of ponderings...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am using a DataGrid for display purposes only and would like to deactivate much of the default functionality as far as the user clicking on it. I have tried overridding OnMouseDown, but when the user clicks on a cell it still gets selected and goes into input mode. I need to disable this kind of behavior, but I still want to capture mouse events so I cannot really set Enabled = false.
My thought was to cover the client area of the DataGrid with a Panel. However, the Panel would need to be transparent, and I don't know how to do this. Is is possible? Is there a better solution?
Thanks!
Mark Mokris
|
|
|
|
|
Why not bind your DataGrid to a DataView that disables what you don't need? You can do so like this:
DataView view = new DataView(dataSet1.Tables["MyTable"]);
view.AllowDelete = false;
view.AllowEdit = false;
view.AllowNew = false;
dataGrid1.DataSource = view; Using a DataView makes it easier to manage sorting and filtering, although you can still do that when binding to a DataSet or DataTable using the DataSet.DefaultViewManager .
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi Heath,
Thanks for the response. I had already tried what your saying, but still when the user clicks on a cell, it gets selected and a text cursor appears. You will not be able to type anything, but I'd like to avoid the text cursor appearing.
Does anyone know, is it possible to create a transparent panel?
Thanks,
Mark
|
|
|
|
|
Yes, I do, but that's not the right way to do it and will only be supported on Windows 2000 and newer (for Windows NT platforms). This uses the SetLayeredWindowAttributes native API that you must P/Invoke, something we've discussed in this forum before and which a few articles on this site discuss.
However, there's still better ways. If you just don't want the DataGrid to respond to any user input (at least on cells, which begs the question of why you're even using the DataGrid then when either using a ListView or just drawing the items yourself would be sufficient), then use the DataGrid.HitTest in conjunection with overriding OnMouseDown to make sure that when a user is over a cell you don't call base.OnMouseDown to continue processing the notification message (WM_LBUTTONDOWN ). This allows you to maintain the normal mouse message processing for other parts of the DataGrid while maintaining functionality for all supported platforms on which the CLI is implemented.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Is there a control I can add to the textbox that is like the "formatting bar" in Word. I need the user to be able to choose font, color, etc... The question is, do I have to make that panel/bar from scratch or can I import it as a control from anywhere?
|
|
|
|
|
You'll have to either write your own Toolbar code to handle what all the buttons are supposed to do or you can use a commercially available control to handle the Toolbar, still writing the code that does what the buttons say they do.
A Textbox has very few properties that make it useful for editing and formatting like this. Why not use a RichTextBox control instead?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
What I meant by textbox is RichTextBox, sorry. But is there a control for that or will I still have to write my own?
|
|
|
|
|
A Toolbar is just a collection of buttons and other controls. Clicking the button will fire an event that signals such, but it will not do whatever the button image says on it's own. You have to supply the code to Save, for example, or Save As, or change the Font of the selection and so forth. There is nothing that will do this for you.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
If a user clicks on a cell in a dataGrid is there any way to return the row number of the cell they clicked (or double clicked) on?
Thanks.
|
|
|
|
|
|
Hi everyone,
I've been stuck with this problem for several days already. My code extensively uses asynchronous delegate invocation using the Delegate.BeginInvoke method. The general pattern is as follows:
Scheduler or UI thread:
1) BeginInvoke function 1
First function:
1) prepare data
2) BeginInvoke data processing passing CurrentThread (see below)
3) CurrentThread.Suspend
4) (after resume) go to step 1 with new data processing command, if all commands are executed, exit
Data processing:
0) get calling thread (passed in parameters)
1) process data
2) set result
3) resume calling thread
Several data processing commands (Command pattern) require asynchronous calls, too. That is that BeginInvoke method is called from inside another method which was called using BeginInvoke, too. What I've noticed so far is that sometimes the delegate being BeginInvoke'd is NOT CALLED AT ALL! To give more evidence, I have a special Logger class which sends messages to a text box. Apparently, it uses Control.BeginInvoke to correctly dispatch Text property changes. Sometimes again the function specified in MethodInvoker delegate is also NOT CALLED AT ALL!
What could be the problem? I honestly hope it is not a bug in the framework, as the project is (and has been for the last month) in the final stage.
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|
Serge Lobko-Lobanovsky wrote:
First function:
1) prepare data
2) BeginInvoke data processing passing CurrentThread (see below)
3) CurrentThread.Suspend
4) (after resume) go to step 1 with new data processing command, if all commands are executed, exit
I've got a question. Why are you launching another thread and then pausing the current one, waiting for the newly launched thread to complete? There's no reason to launch another thread to do the work if your just going to sit around and wait for it to complete!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|