|
No, and that's why I described it as "a few lines"
you probably want a foreach loop.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
That's what I ended up doing. thanks, -Kevin
|
|
|
|
|
Kevin
You should add a break statement to your inner foreach loop after adding the item to the list. This will ensure that the current family from the outer loop is not added multiple times to the available list if it is not already assigned to the contact.
Paul
|
|
|
|
|
Thanks Paul, This managed to remove all but one of my duplicates in my available list. I put the break; inside the if statement.
-Kevin
|
|
|
|
|
Kevin,
kboyette wrote: My code for this works fine if there is only one assigned family but if there are more then I get duplicates in the available families list. I've thought of a couple of ways to accomplish this but none of them are elegant.
i believe you are calling your families list from a DB using a T-SQL statement.
You can use the 'distinct' keyword in your sql statement to retrieve unique values.
For ex: select distinct [familynames] from familytable
does it work well?
-- modified at 8:08 Friday 17th August, 2007
He who goes for revenge must first dig two graves.
|
|
|
|
|
Hi there,
Well, my problem is pretty straightforward. I need to control access to a particular directory through a bit of C# code. I also need to toggle this security mode between 'access denied' and 'access granted' modes whenever I need.
How can I do this?
Regards,
A
|
|
|
|
|
You can't really. Well, not without writing, in C++, hooks into the Windows File I/O API's to capture the requests. You can NOT do this in C# because of the requirements of "DLL Injection" to get this to work.
This just handles the File I/O part. Then you've got to write another app, which CAN be written in C#, that manages the access and the user database, and maybe a utility to fix any problems with said database.
It's simply not worth it. You get nothing above and beyond what the standard NTFS security system gives you, other than an administrative nightmare.
|
|
|
|
|
You can use the DirectorySecurity and FileSystemAccessRule classes to do this. There aren't any DLL injection concerns here at all. These classes rely on the underlying Win32 APIs to manipulate the ACLs assigned to the filesystem.
|
|
|
|
|
Scott Dorman wrote: You can use the DirectorySecurity and FileSystemAccessRule classes to do this.
Which is all NTFS security... Not exactly the solution his description spelled out, but it would work. Personally, I think his requirements are a bit over the top. In 22 years, I've never heard of anyone needing a security solution like this for any reason what-so-ever.
|
|
|
|
|
Disclaimer... not sure if this will work for your case -- this is the first time I've used this and I havn't really looked into it much.
Doing this I was able to restrict access to a directory that I had just created.
DirectoryInfo dirinfo = new DirectoryInfo(@".\mydir");
DirectorySecurity dirsec = new DirectorySecurity();
WindowsIdentity.GetCurrent().Name.ToString();
FileSystemAccessRule fsar = new FileSystemAccessRule(WindowsIdentity.GetCurrent().Name.ToString(), FileSystemRights.FullControl, AccessControlType.Deny);
dirsec.SetAccessRule(fsar);
dirinfo.SetAccessControl(dirsec);
Basically this restricts it for the current user, but you can change it to the user name you'd like by replacing the WindowsIdentity name to whatever user you want.
Include these namespaces:
using System.IO;
using System.Security.AccessControl;
using System.Security.Principal;
|
|
|
|
|
Hi,
I have been fighting this problem for a couple of days now, I have a application where the user uses userid and password to log-on. My app goes to the database verifies user info and if the user has not changed his/her pswd for 90 days need to pop up a msg to user asking her/him to do so
I use the following code in button click event (after going to the db and verifying), am not sure if this is correct, does not work
StringBuilder sbScript = new StringBuilder();
sbScript.Append("alert('");
sbScript.Append("Change password");
sbScript.Append("')");
ClientScript.RegisterClientScriptBlock(this.GetType(), "pswdrem", sbScript.ToString());
can anyo1 help?
|
|
|
|
|
vis, CodeProject has a ASP.NET forum. Look in the Forum list.
|
|
|
|
|
Try Response.Write("<script language= 'javascript'>alert('Change Password');</script>);
I agree with led. you should better ask in right forum....
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Michael Sync wrote: Try Response.Write(
That will put the script outside the html document, which breaks the doctype.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: That will put the script outside the html document, which breaks the doctype.
Yes. I know. I have seem a lot of ASP.NET project to do that way to fire the Javascript code. It works just fine.
Guffa wrote: , which breaks the doctype.
What will happen if it breaks the doctype?
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Michael Sync wrote: I have seem a lot of ASP.NET project to do that way to fire the Javascript code. It works just fine.
The Javascript works, but the page doesn't work properly.
Michael Sync wrote: What will happen if it breaks the doctype?
The page will be rendered in quirks mode instead of standards compliant mode.
---
single minded; short sighted; long gone;
|
|
|
|
|
Guffa wrote: The Javascript works, but the page doesn't work properly.The page will be rendered in quirks mode instead of standards compliant mode.
Okay. I think it's very interesting. The developers from my team used a lot like that. Since we didn't see any differences on UI until now, we keep on using that thing. If it doesn't work properly, I have to think about something else.
But we need to ensure how the page doesn't work properly. So, It would be great if you can point out the differences. How the page will look like if we are using Response.Write("")??
Thanks in advance.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
How much difference you see depends of course on how you build your pages, and what browser you are using to view them. If you are using html 3.2 and table based layouts, you will probably see very little difference. If you are using more modern techniques, you will see more differences, and Internet Explorer is much more sensetive to this.
Here is a short example that uses css:
<script type="text/javascript">alert(1);</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<style type="text/css">
body { margin: 0; padding: 0; }
div { margin: 0 auto; border: 50px solid #eee; width: 150px; padding: 10px; text-align: center; }
</style>
</head>
<body>
<div>Hello world.</div>
</body>
</html>
If you view this without the script tag at the beginning, it shows a 150 pixels wide box centered horizontally.
With the script tag, viewed in Internet Explorer, the box is no longer 150 pixels wide, and it's not centered.
---
single minded; short sighted; long gone;
|
|
|
|
|
Oh. Okay. Guffa. I got you.... I think our team is using table-based layouts that's why we can't see the differences.. we are thinking to use CSS-layout instead of table-based layouts in future. it is going to be problem..
Thanks for pointing this mistake and giving me the example..
You got 5 from me.. Thanks again..
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hey all,
please, once again, critical help needed here.
wanna ask if it is possible to convert c++ code to c#. Or can i convert the .cpp files to DLLs and import into my c# project.
Also can i do the same for .java files?
Critical answer expected.
Thanx.
He who goes for revenge must first dig two graves.
|
|
|
|
|
Yes.
Phil
The opinions expressed in this post are not necessarily those of the author, especially if you find them impolite, inaccurate or inflammatory.
|
|
|
|
|
Phil,
pls be clear. Yes to what?
He who goes for revenge must first dig two graves.
|
|
|
|
|
Creamboy wrote: Or can i convert the .cpp files to DLLs and import into my c# project.
yes. look at pinvoke.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
ok, there's another problem. How do i convert them to dll?
He who goes for revenge must first dig two graves.
|
|
|
|
|
Creamboy wrote: ok, there's another problem. How do i convert them to dll?
I think there is also another problem
|
|
|
|