|
I also try to figure it out daku1..i use Session.RemoveAll() in my logout page and redirect it to my login page. But if i push back button in my browser it redirect me to my last page(for example: viewpage.aspx),and in that page i try to push my link page or any button and it tell me must to login first.
Did u already have a session check in all your web pages, that tell user to login first if the session is null?
Regard,
TCim
|
|
|
|
|
I am looking for some help with .chm files and integrating them into my program, does anyone know of an information on this?
|
|
|
|
|
|
assuming your chm file is indexed couldnt you use the help provider class within windows forms 2.0 ?
|
|
|
|
|
Does anyone know of a class that can convert a string in the c# string literal format to a regular .NET string and vice versa? I want to have a designable string property that allows special characters and I figure a TypeConverter that supports the c# string literal format is probably the easiest way to do it, unless there exists a better way?
Thanks
|
|
|
|
|
Maybe some examples of the required conversion would be helpful...
|
|
|
|
|
Say you had a textbox with a property named "WhiteSpaceChars" of type string. Each char in the string is what should be a white space character.
the default value for this string would be (in c# code)
whiteSpaceChars = " \t\r\n";
Now I would like that string to show up in the property designer for users to be able to edit. Now obviously the default string TypeConverter in windows forms can't handle these particular characters. However if I had a TypeConverter that could handle the c# string literal syntax my problem would be solved.
This goes both ways, if the user types in a value of
\x00010
I would like the appropriate string returned to my class as if it were a string literal.
|
|
|
|
|
Hi,
if your only concern is the one backslash/two backslashes issue, you can convert back and
forth with a simple method. I dont think it is provided by .NET, so you would have to
write it yourself (I'll use curly braces to indicate a single char):
say input is ab\tc\nd then output would have to be ab{TAB}c{NEWLINE}d
you can do sequential replacement of \t by {TAB}, then \n by {NEWLINE} etc
using String.Replace
the order is irrelevant, since old and new strings do not conflict with each other.
similar method is required for the other direction.
if you also want to replace the \x#### and \u#### character codes by their actual char,
things become more complicated. Do you ?
|
|
|
|
|
Yeah I think you're right, a tagged expression would be much more easily parsed. Even a {x####} and {u####} could be easily extracted with some simple regexps.
Thanks!
|
|
|
|
|
Hi,
to enable some additional functions for me in my program during developing, I have defined the preprocessor directive "#define debug" at the beginning of each code-file. But it is a bit troublesome to set respectively unset this line on each file when I toggle between release and debug build.
Is there an easier possibility to do this? Can I somehow request in the code wheather it is built as debug or release?
Thanks in advance,
Alex
|
|
|
|
|
Have you looked in the Project Properties, Build tab?? Under General, there's a "Conditional compilation symbols" box where you can put names that will be #defined for the compile. The DEBUG checkbox automatically #defines DEBUG for the entire project compiled under the Debug build configuration. For a Release build, those symbols are removed.
|
|
|
|
|
Friends:
I defined a method with a generic value type parameter as follows, but it does not compile (Operator '-' cannot be applied to operands of type 'T' and 'T'; Operator '>' cannot be applied to operands of type 'T' and 'T').
//Declaration
public class Algos
{
public bool CompValues <t> (T t1, T t2) //the generic sign after CompValues was deleted automatically by the website
{
T dif;
dif = t1 - t2;
if(dif > t1)
return true;
else
return false;
}
}
//Calling
Algos al = new Algos();
al.CompValues<int>(5, 3); //the generic sign enclosing "int" after CompValues was deleted automatically by the website
Whether I add constraints or not :"where T: struct" and/or "where T: IComparable<t>", it does not compile. Why?
Thanks!
-- modified at 14:30 Friday 20th July, 2007
Sheng
|
|
|
|
|
|
Kevin:
I does NOT compile. You can try. Or I have to add some "using" reference?
Sheng
|
|
|
|
|
You might want to re-read Kevin's post. What you want to do, at least how your doing it, isn't possible!
You're assuming that a minus operation is possible on ANY TWO OBJECTS you give this code and that's just not the case. THAT'S what the compiler is trying to tell you! Your code, if it were to compile, leaves open the possibility of
dif = SqlConnection - SqlConnection, which, obviously, isn't valid.<br />
<br />
<br />
<br />
<div class="ForumSig"><small><a href="http://www.codeproject.com/scrapbook/ForumGuidelines.asp">A guide to posting questions on CodeProject</a>[<a href="http://www.codeproject.com/scrapbook/ForumGuidelines.asp" target="_blank" title="New Window">^</a>]</small><br><br />
<font color="Blue">Dave Kreskowiak<br />
Microsoft MVP<br />
Visual Developer - Visual Basic<br> 2006, 2007</font><br />
</div>
|
|
|
|
|
Yes. Did you read the links? It's not compilable. You cannot use operator < with generics. It's a limitation. It's possible with C++ but not with .NET.
Kevin
|
|
|
|
|
Okey! I give up trying. The constraint clause "where T: struct" isnt' working either. The constraint clause should have allowed to specify particular types, for example: "where T: System.ValueType". In fact, it does not. It's a deficiency of C# language.
Guys, thanks!
Sheng
|
|
|
|
|
You really need to go back and read the Generics section again. The constraints WHERE clause only works at the class level, not the method level. Such as when making a custom collection of objects.
public class EmployeeList<T> where T: Employee, IEmployee, IComparable<T>, new()
See this[^], and this[^] for examples.
|
|
|
|
|
Hi Dave.
I find his question interessting, and I wonder if this might be possible?
public bool CompValues (T t1, T t2)
{
bool result = false;
if(typeof(t1) == typeof( Value Type here))
{
ValueType var1 = (t1 as ValueType);
ValueType var2 = (t2 as ValueType);
}
else if...
else
{
throw new Exeption("Invalid comparison type.");
}
return result;
}
Or perhaps check type of T against typeof(IComparable) ?
Best regards!
-Larantz-
|
|
|
|
|
It's possible, but when you replace ValueType with your actual type, like int , you really haven't gained anything. This would result in you doing what is already being done. Overloading the Compare method to handle each supported type.
He's trying to use Generics to do something it doesn't support. Since the Value types all implement IComparable already, it should have been written like that:
public int CompareValues(IComparable v1, IComparable v2)
.
.
.
But, again, this already exists is each value, so what he's trying to write is redundant.
|
|
|
|
|
Hi, this is my first post on here so we'll see how it goes.
I am trying to write a method that uses a number of thread to populate an object and then return the object. The problem is that I never know when the threads are finished. I thought about having a counter and it will add when the thread finishes, and then have a Timer check every few seconds and see if the numbers match; however, the it is still a hack and I cannot return my object in the timer event. Any ideas?
public IApplicationPrivilegeCollection GetAllUserPrivileges(string userName)
{
Precondition.NotNullArgument(userName, "userName");
IDatabaseInfoCollection databaseInfoCollection = _databaseInfoRepository.getAllDatabases();
IApplicationPrivilegeCollection applicationPrivilegeCollection = new ApplicationPrivilegeCollection();
int applicationCount = 0;
foreach (IDatabaseInfo databaseInfo in databaseInfoCollection)
{
BackgroundWorker worker = new BackgroundWorker();
IApplicationPrivilege list = new ApplicationPrivilege();
worker.DoWork += delegate(object sender, DoWorkEventArgs e)
{
worker = sender as BackgroundWorker;
list = GetUserPrivilege(userName, (IDatabaseInfo)e.Argument);
}
;
worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e)
{
applicationPrivilegeCollection.Add(list);
applicationCount++;
};
worker.RunWorkerAsync(databaseInfo);
}
return applicationPrivilegeCollection;
}
|
|
|
|
|
Your design doesn't make any sense. Your GetAllUserPrivileges method is designed to be a blocking method but then you set off multiple async threads inside it to perform the work.
Try a design where GetAllUserPrivileges does NOT block and you fire an event that contains the desired result object as an Event argument.
|
|
|
|
|
I am not sure I understand you. What do you mean by it being a blocking method? I am new to threading and am actually just using a BackgroundWorker to make it easier.
I think I know what you mean by having a result object; however, the method runs fine right now if I just put a while loop in it and wait for all the threads to finish. I just need a nicer way to detect if all the threads are finished.
I don't understand why you think my design doesn't make sense. I need to set off multiple threads inside a foreach because that is the whole point of using threads here.
|
|
|
|
|
dilucidate wrote: I am not sure I understand you.
dilucidate wrote: What do you mean by it being a blocking method?
dilucidate wrote: I am new to threading
dilucidate wrote: I don't understand why you think my design doesn't make sense.
Text messages are not a good format for discussing a topic as complex as threading. There are good resources available for developers that want to "understand" how and why to properly use threads. An old book that I found very useful was Advanced Windows by Jeffery Richter. Also I have seen several people give a link to a web site with a threading tutorial. Perhaps Google can find it for you.
dilucidate wrote: I am new to threading and am actually just using a BackgroundWorker to make it easier.
"Easier" is not how I would describe your code. Have you ever heard of the K.I.S.S. principle? It means Keep It Simple Stupid.
|
|
|
|
|
Please suggest me proper method to make my Panel recieve Input Focus.
My Requirement is that I have 2 buttons, followed by a Panel and then a List.
I should be able to transfer the focus from First Btn, 2nd Btn, Then Panel and finally the ListBox. Everything is fine but I cannot get the Panel to recieve Keyboard Focus.
I'm using .NET 2.0 SDK.
Thanks
PS: I know that .NET 3.0 has Control.Focusable Property
|
|
|
|