|
Same way I mentioned before. Read about the Page.User property. If you need help specific to SharePoint, I suggest you try a search for "SharePoint" on google[^]. There's many sites full of helpful information. Your problem is not specific to C#.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Thankyou, with ur help i am able to get the details of the user who has logged-in into the portal server. I have another problem. I have a webpart and depending on the user who has logged in, i need to display a webpage. I am unable to do it, any suggestion?
|
|
|
|
|
When I initially started .Net Forms I was gladdened by the provision of the Dock property and used it everywhere in resizable forms. It saved all the layout functionality that used to have be written in the Resize event from VB. However there were occasions when I would have to Dock a Panel in the form with a padding and then dock other controls inside that to get the right look and feel.
So then you look a little closer at the .Net offerings and discover that you can avoid these extra controls by using Anchor instead.
My question is one of developer choice. Is there a preferred method out there that people are using to layout their UI's? Does anyone favour Anchor over Dock?
|
|
|
|
|
I used to prefer anchoring controls (people with a Java background might prefer docking ), but meanwhile mostly converted.
The reason was that with visual inheritance you'll get weird/incorrect results when you anchor a control to the right or lower border of the container and this container is resized in a derived form. That's why I try to use docking now wherever I can.
mav
|
|
|
|
|
You should not base your usage of Dock vs. Anchor on preference, but requirements. Dock and Anchor do two different things, but they can seem similar when you anchor opposing sides. It's the ability to anchor adjecent sides that makes the two unique. If you want a Button to always stay in the lower-right corner, you anchor it to the bottom and right sides. You can't do that with docking. All you can do is dock to the bottom, but that will also work like anchoring it to the left side in addition. What you're left with doing is using a complex hierarchy of controls like the Panel or other container controls to support this. The extra window handles to track - not to mention the extra memory for these controls - is not required.
Also, some container controls allow you to set the padding for docked child controls, but this still doesn't afford you the same level of control for anchoring. You can anchor a control 8 pixels from the left edge of a parent control and 16 pixels from the top, and it will stay there (for example, depending on the anchored sides). With docking, that is much more difficult.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
Hi All,
i've a tricky little problem with AutoScroll functionality that i can't seem to overcome. I have a panel with its autoscroll property set to true. On the panel i have several combo boxes which are surrounded by some graphics implemented with GDI+. My problem is as follows .. say a combo box at the bottom of the panel has focus, when i click on the panel i want it to gain focus but not refresh and redraw itself at its initial position i.e. (0,0). In other words when the panel gets focus i still want to be able to view the combo box at the bottom of the panel which had previously been the active control.
Is there any way of preventing the panel from redrawing itself at its initial (0,0) position???
Or is it possible to calculate the autoscroll position prior to giving the panel focus then explicitly setting the autoscroll position to the desired position.
Any ideas and suggestions are very welcome and appreciated!
Thanks,
Paul Griffin
|
|
|
|
|
Simple math and the ScrollableControl.AutoScrollPosition (inheritted by derivative classes like Panel ). Just be sure to read the .NET Framework SDK documentation about when to use client- and screen-based coordinates (which can be easily converted using methods like Control.PointToClient and Control.PointToScreen ).
If you have a ComboBox that is partly hidden and want to make sure that it's completely visible without scrolling it to the client point 0,0 for its container, find out how much is hidden and offset the current AutoScrollPosition by that amount:
int offset = comboBox1.Bottom - this.Height;
Point p = this.AutoScrollPosition;
p.X -= offset;
this.AutoScrollPosition = p; This is only an example, but hopefully gives you some idea. Also, do not simple set AutoScrollPosition.X to something. A Point is a value type - not a reference type - and needs to be copied first before being modified. If you set AutoScrollPosition.X to some offset, you'll notice no change because a copy was made but never assigned to AutoScrollPosition again.
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 your response! Your suggestion is actually the way i had approached the problem. In the MouseDown event handler for my panel i create a vertical offset from the MouseEventArgs e.Y. as follows:
int offset = e.Y ;<br />
this.myPanel.Focus();<br />
<br />
Point p = this.myPanel.AutoScrollPosition;<br />
p.Y = offset;<br />
this.myPanel.AutoScrollPosition = p;
When i debug the code i see that p does get initialised to the correct value but the assignment to AutoScrollPosition never works. AutoScrollPosition always remains (0,0)???
Any ideas as to what is happening here??
Thanks again!
Paul Griffin
|
|
|
|
|
Your offset isn't an offset at all. You need to off-set the current Point (the AutoScrollPosition ) by a certain amount like I did in my example. What you're doing now would make the Location of your control scroll to the top which would be 0,0 (the position within the container control).
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,
sorry if i seem to be missing the point! Perhaps i need to re-phrase what it is i'm trying to accomplish. I'm trying to get a panel with AutoScroll set to true to scroll to a certain location i.e. the location last clicked before i gave focus to the panel thus causing it to redraw at its initial position.
No in your example you use this.AutoScrollPosition = p;
i assume for me this would be mypanel.AutoScrollPosition = p;
but when i do this and debug it if i step over the assignment the AutoScrollPosition value = (0,0);
so i understand that i need to offset the AutoScrollPosition .. i just can't seem to get it to change from (0,0)
again i appreciate your help here! this is starting to drive me mad!
Paul Griffin
|
|
|
|
|
It's what you do to the Point before assigning it back to mypanel.AutoScrollPosition that matters. If you haven't already, read about the ScrollableControl.AutoScrollPosition and pay close attention to the the note just before the example.
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,
just to let you know i finally cracked it, a combination of thinking about your posts properly and spotting a very stupid mistake i was making.
Thanks a lot for your replies!
Paul Griffin
|
|
|
|
|
Reading that back still didn't sound right i'll try one more time.
The sequence of events are as follows:
1. My panel receives focus and using the mouse wheel or scroll bar itself i scroll to some point on the panel.
2. I click on a second control e.g. a combo box.
3. I'm now finished using the combo box and i would like the panel to regain focus so that i can continue scrolling it.
4. I click back onto the panel, the panel_MouseDown event handler fires in which i include the line panel.Focus();
Problem:
Each time this line is executed the panel redraws itself with the scrollbar at its initial position and i have to scroll all the way down to where i was before i can continue to the next control lower down on the panel.
May sound like a trivial problem but as i've said repeatedly the functionality to set the scroll bar position explicitly doesn't seem to be there!
There hope that describes the situation a bit more clearly!
Paul Griffin
|
|
|
|
|
Hi everybody,
I am developing a game for a pocket pc. There are picture boxes with images loaded @ runtime that forms a rectangle like shape.
How u play is , u have to create chains(draw line) combining images of same type (there are 4 types of images). To do this I need to find the shortest path between 2 images and the path should not be blocked by any other type of image.
A line also need to be drawn joining the images.
Can anyone please help me!!!!!!!!!!!!!!!!!!!!!
Thanks
Casper
|
|
|
|
|
Hi,
I am developing a game for a pocket pc. There are picture boxes with images loaded @ runtime that forms a rectangle like shape.
How u play is , u have to create chains(draw line) combining images of same type (there are 4 types of images). To do this I need to find the shortest path between 2 images and the path should not be blocked by any other type of image.
A line also need to be drawn joining the images.
Can u please help me!!!!!!!!!!!!!!!!!!!!!
Thanks
|
|
|
|
|
Have a look at C# : A-Star is born or at Quickgraph
Or look for "Dijkstra algorithm" on google.
Maybe post/send some code to explain the situation... curous as how it all looks myself.
|
|
|
|
|
I had a previous post regarding how to design a socket based client-server system with C#.net which will scale very well. http://www.codeproject.com/script/comments/forums.asp?msg=913692&forumid=1649#xx913692xx[^]
Heath gave a very interesting response, which told me:
(1) Use Web Services or .net remoting to free yourself from the socket level details
(2) Try to use WSE DIME for file transfers
I am reading on these.
A further question in this context:
I have observed that many clients do not allow incoming http connections inside their firewall. They typically have the DMZ firewall configuration. The Web Server will be in the DMZ and app servers will be inside. They also do not permit to have their business logic sitting on the IIS machine.
So even though I have a Web service based entry to my system, it still has to do socket communication with my server sitting inside the firewall over an admin allowed port.
Browser/WinForm Clients
<->DMZ<-> [Allows only http]
Web Service (IIS)
<->Firewall<-> [Allows only my chosen port]
My Server (With DB/NTFS/Network access)
Am I missing something? Are there any better options?
|
|
|
|
|
In the scenario you described, your solution is correct. But again don't consider simple socket communications. .NET Remoting can work over any port without IIS, you just need a different host. Windows Services, for example (those deriving from ServiceBase and installed with the ServiceInstaller and ServiceProcessInstaller classes), make great hosts.
The solution depends entirely on your network topology. If your external web servers sits in a DMZ and has limited access to the inside network through well-known ports (like HTTP), then one solution is to use .NET Remoting or Web Services to talk to an internal web server (perhaps a virtual end-point for SQL Server, even) through port 80 (or whatever port the web server is configured on).
There's not a single solution for any given scenario.
To learn more about .NET Remoting, I recommend picking up "Microsoft .NET Remoting" from Microsoft Press[^] or "Advanced .NET Remoting" from Ingo Rammer[^], both very good books (although the latter is for intermediate and advanced .NET Remoting developers, while the former is for beginning and intermediate .NET Remoting developers).
The only point I was making before was that the wire protocol isn't enough. You still need to define a data transfer protocol with any application and platform. .NET Remoting and Web Services (which are an industry standard and not specific to .NET) describe both. .NET Remoting is comrised of independant wire and transfer protocols (i.e., binary or SOAP over HTTP or TCP - "out of the box"), while Web Services use SOAP over HTTP.
If you want to use sockets, you'll need to define your own protocols.
This also depends on legacy systems, too. If you have a legacy socket server in place and want to continue using it, then you'll have to use the protocol you already defined with the socket classes in the BCL.
The nice thing about Web Services is, though, that many legacy servers now support HTTP daemons, which aren't too hard to implement (basically) anyway. Developing a Web Services need not be hard, either, so long as you explore the SOAP and WSDL specifications and implement them accordingly. I've seem scenarios where older AS/400s implemented Web Services. IBM was a key player in the push for Web Services, so many of their upgraded OS images support them through WebSphere or some other system (I must admit I don't follow IBM these days).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
I tried to do some C# for the first time and decided
to try and use one of my C++ COM classes from it.
Using the class from C# gives this definition of a method.
MyInterface1.A(out MyInterface2 ppIFace)
Trying to call it as this will fail with a syntax error.
MyInterface2 IFace2;
MyInterface1 IFace1;
IFace1.A(IFace2)
How do i call this method from C# ?
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
With C# you'll have to specify if a parameter is a ref or out parameter not only at the method declaration but at every call.
So writing
IFace1.A(out IFace2); should do the trick.
Regards,
mav
|
|
|
|
|
Oh..that simple, thanks.
/Magnus
- I don't necessarily agree with everything I say
|
|
|
|
|
In Web Application, Use File.Exists(filename) method,don't find the file that in network folder?
|
|
|
|
|
That is kind of a generic question but it should. Why not try it and find out instead of asking here? 
|
|
|
|
|
File.Exists works on physical files. In an ASP.NET web application (or even an ASP web application, or many other web application frameworks), paths are virtual. They map to a physical path but not automatically.
To map a virtual path to a physical path in ASP.NET, use Server.MapPath or Page.MapPath depending on your context. If your code was in a page, for example, you would use:
if (File.Exists(MapPath("/path/to/file.aspx")))
In the future, please direct ASP.NET-related questions to the ASP.NET forum regardless of what language you're using. The ASP.NET forum is specifically for ASP.NET-related questions.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles]
|
|
|
|
|
An issue to consider: asp.net runs (by default) under a user account on the local machine (the web server, that is.). Chances are good that this account does not have access to the files you are trying to reach on the network folder, so Exists() will always return false.
The only solution I've found if I REALLY need to access files across the network from within asp.net code is to impersonate. Since this is a little involved, I am not going to take up community bandwidth unless you are sure this is what you need to do.
It would make life much easier if you can get all the files onto the webserver. If you cannot, please post if you need details, I'll post an example.
Hope this helps,
Bill
|
|
|
|