|
hi
i have a login control to my page, it's work good,but when i at runtime set RememberMe checkBox to true and refresh page or recompile it, the checkbox is empty and not remember me, how to solve this problem ?
thanks
|
|
|
|
|
Here's what I use.
A few things to note:
1. I started with http://www.codeproject.com/useritems/Remember_me_next_time.asp[^]
2. I didn't want the password stored, so that is commented out
2b. Since the password isn't available, the automatic login is commented out
3. You should probably change the name of the cookie
Enjoy
Brad
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Request.Cookies["LoginCookie"] != null)
{
HttpCookie cookie = Request.Cookies.Get("LoginCookie");
this.Login1.UserName = cookie.Values["ID"].ToString();
}
}
}
protected void Login1_LoggedIn(object sender, EventArgs e)
{
CheckBox rm = (CheckBox)Login1.FindControl("RememberMe");
if (rm.Checked)
{
HttpCookie myCookie = new HttpCookie("LoginCookie");
Response.Cookies.Remove("LoginCookie");
Response.Cookies.Add(myCookie);
myCookie.Values.Add("ID", this.Login1.UserName.ToString());
DateTime dtExpiry = DateTime.Now.AddDays(15);
Response.Cookies["LoginCookie"].Expires = dtExpiry;
}
}
}
|
|
|
|
|
Hi,
I am learning a little C#, and I would love to be able to create a little graphical form with a few buttons on it that will allow me to execute the XP / 2003 SHUTDOWN command.
Ideally I'll have just a handful of buttons, each named after a server, and hitting that button will execute the proper shutdown /r /m \\machinename command, assuming of course that the user has the appropriate permission to reboot \\machinename.
Can this be done? I would like any console access to be hidden, so no DOS box pops up, but that isn't really so important, I can figure out how to do that later.
For now I'm stumped about how to pass a DOS command from a C# GUI.
Would anybody be kind enough to toss me a bone?
Thanks!
|
|
|
|
|
You will need the Process and StartInfo classes, something like:
Process proc=new Process();
proc.StartInfo.FileName="my command";
proc.StartInfo.Arguments="my command arguments";
proc.StartInfo.CreateNoWindow=true;
proc.StartInfo.UseShellExecute=true;
proc.Start();
to organize some details, you may want to set other properties in StartInfo before
starting the process...
Luc Pattyn
|
|
|
|
|
Thank you - when I add this code into my Button, it complains:
Error 2
The type or namespace name 'Process' could not be found (are you missing a using directive or an assembly reference?) C:\<path edited="">Form1.cs
|
|
|
|
|
As it says, you need to add a using statement, in this case:
using System.Diagnostics;
near the other usings already in your file.
May I also suggest you read the MSDN documentation on any classes you decide to use...
Luc Pattyn
|
|
|
|
|
Interesting, that did get me closer to where I want to go, perhaps enough so that my limited knowledge can leverage the MSDN enough to get running.
Thank you very kindly Luc, I appreciate your helpful kindness.
|
|
|
|
|
Hello everyone,
My question is simple (-but the answer may not ) : is it possible to create folders (and/or files) that only allowed programs can access ?
For example; I want to hold some of my audio files in a special folder that only "myAudioPlayer" application can open..
Thanks for your helps and best regards !
Also have nice year !!!
.:: Something is Wrong ::.
|
|
|
|
|
I dont think so...
Luc Pattyn
|
|
|
|
|
The File System is responsible to protect files and folders. The access limitation is defined by account (Windows' users and groups) and permissions (read, write, delete, etc.). You cannot set access permission by application.
Not every file system supports file access protection. NTFS supports, FAT doesn't.
Ami
|
|
|
|
|
For example isn't it possible to set a registry value when you start your app and reset the value when you exit ? And if that registry value is empty the folder may not open ?
I am searching for a couple of hours but found nothing ..
Should I use the WinAPI ? Or the namespace extension, shell etc. ?
There must be something, and I am ready to spend my weeks on this topic...
.:: Something is Wrong ::.
|
|
|
|
|
pashje wrote: isn't it possible to set a registry value when you start your app and reset the value when you exit ? And if that registry value is empty the folder may not open ?
No, it's not. If your in Explorer or some other app, what's going to check that registry setting to see if it's OK to open the file??? Nothing!! You'd have to write an NTFS extension to implement this kind of functionality, and even then, it's easily defeated because it won't work on a FAT32 volume.
pashje wrote: I am searching for a couple of hours but found nothing
And you never will find anything, because it's not possible. Well, not without LOTS of extra work.
pashje wrote: There must be something, and I am ready to spend my weeks on this topic...
Quite wasting your time. This functionality won't exist unless you write an NTFS extension to do it. And even then, it won't work over networked folders.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Create a special user account and restrict access to the file and directories. Then, in your application, you can impersonate. It really won't stop anything but then again, any user with physical access can do anything they want anyway.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
I show images on form, i wanna show image with "Windows Image Fax Viewer" when user clicks on any image.
How could i do ?
|
|
|
|
|
you could try something like this:
void OpenImageViewer(string f) {
Process proc=new Process();
proc.StartInfo.FileName=@"C:\WINDOWS\system32\rundll32.exe";
proc.StartInfo.Arguments=@"C:\WINDOWS\system32\shimgvw.dll,ImageView_Fullscreen "+f;
proc.StartInfo.UseShellExecute=true;
proc.Start();
}
Luc Pattyn
|
|
|
|
|
On the other hand, if you just want to open a file with its default tool (as if
you double-clicked it in Windows Explorer), you would need:
void OpenDefaultTool(string f) {
Process proc=new Process();
proc.StartInfo.FileName=f;
proc.StartInfo.Arguments=null;
proc.StartInfo.UseShellExecute=true;
proc.Start();
}
Luc Pattyn
|
|
|
|
|
Before you ask, you will have to include a "#using System.Diagnostics" in the
first part of your file, next to other using statements.
Luc Pattyn
|
|
|
|
|
Hi All
I want to display a line graph in a Panel or should I be using a picturebox or textbox. I have code that will a;;ow me to do all the calculations etc.
Where I am stuck is putting it all together, do I need to create an image of the graph and return this from a method or seperate class and using the this command add it to a panel etc.
Any help vastly appreciated!
James
|
|
|
|
|
You can draw the graph yourself in a panel.
Attach a paint handler to its Paint event; inside the handler get its Graphics, and do the
Graphics.DrawLine() and other calls as you see fit.
Luc Pattyn
|
|
|
|
|
Okay, so I have written my own class library... And have documented it with the inline xml thingy... So... now what?
How do I distribute them to others?
What files do I have to include so that IntelliSense works okay? (Do I have to include the XML file?)
Where do I have to copy those files so VS recognizes them?
Regards,
Vandra Akos
|
|
|
|
|
Distribution:
distribute your xml and dll files together (in the same directory), as Visual does.
Usage:
- add a reference to the dll(s) you need, e.g. using the Solutions pane in Visual Studio
- add a using statement to your client source code
Now the classes in your new dll(s) are available together with their XML comment (for
Intellisense).
Luc Pattyn
|
|
|
|
|
I believe the XML files you are refering to are the XML documentation files which are turned off by default in the project. Building the dll, however, should include the XML comments as they are part of the assemblies meta data.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
I was under the impression axos88 already got his XML file, but didnt quite know
what to do with it...
Luc Pattyn
|
|
|
|
|
I saw a few imaging programs, that use local database for storing data about images and thus provide extremely fast image search (wihtout accessing files).
I want to implement this: database for faster file search in my C# app, but any SQL tutorial begins with installation of some server tools. However, end user does not have these tools. I also cannot force him to install MS SQL Server, because he may not use Windows (my app should work on other platforms).
So I'm confused. Is is possible to use databases as well (in app release, that does not contain huge server tools) or it is better to use some alternative (e.g. store all the data in single XML file)?
Thanks a lot,
Libor Tinka
|
|
|
|
|
Libor Tinka wrote: Is is possible to use databases as well (in app release, that does not contain huge server tools)
SQLite[^] is a small C library that implements a self-contained, embeddable, zero-configuration SQL database engine.
|
|
|
|