|
C# and VB .NET are targetted at slightly different audiences, and that changes the stack rank of features. Many features are interesting to both groups, but the importance of the feature may be high in one group and low in another. Each of the product groups decides where to devote their resources for a given release.
I don't know what the plans are for VB .NET WRT generics. I do know that generics have always been one of the top requests from C# customers, and that's why we're doing them.
|
|
|
|
|
Thanks, Eric.
That clears things up for me.
Cheers,
Simon
"From now on, if rogue states want to buy weapons of mass destruction, they're going to have to go on eBay," Mr. Bezos said.
|
|
|
|
|
I have a situation in which data from a database is extracted via ExecuteReader(), with all of this taking place in the Page_Load event in a codebehind file. The data is then stored in several variables whos contents are displayed on different parts of the page. I now would like to add a usercontrol to make updating the navigation panel easier. However part of the navigation require key data that was extracted from the database.So...
Is there anyway to give 'myusercontrol.ascx' on 'somepage.aspx' access to variables in 'somepages-codebehind.cs' ???
It would be extremely convenient if there were, which is why I'm asking
Otherwise I will have to rewrite the entire way data is access
Thanks for the help.
********************
* SteveMcLenithan
* steve@steve-mac.com
* http://steve-mac.com
********************
|
|
|
|
|
ASP.NET forum question! And no dont double it there too!
Steve McLenithan wrote:
Is there anyway to give 'myusercontrol.ascx' on 'somepage.aspx' access to variables in 'somepages-codebehind.cs' ???
You just need to mark the members (variables) protected public ( ) and then u can use the USerControls Page property to get the page, cast it somepage and whala!
"I dont have a life, I have a program."
|
|
|
|
|
|
I have a rich text control....and a rich text document to display in that control. Is there any easy way to bind that file to the control, or do I have to access the file and stream it into the control at form load?
Thanks
_____________________________________________
I have a tendancy to where my mind on my sleeve I have a habit of losing my shirt...
|
|
|
|
|
Use the RichTextBox 's LoadFile method, there you can give it a filename or a Stream to load from.
If you have the document loaded in memory as a string object then you can just set the Rtf property of the control (or if its unformatted text then the normal Text property will do).
James
- out of order -
|
|
|
|
|
Wow! Thanks. I looked for some kind of binding control at the design stage, rather than methods at runtime. This works great, and SOOOO simple. Thanks.
_____________________________________________
I have a tendancy to where my mind on my sleeve I have a habit of losing my shirt...
|
|
|
|
|
I use the code described below to one-way hash a supplied user's password to verify it against the one-way hashed password stored in a database.
While the code works and provides the functionality I am looking for I am not convinced that it does it in the quickest/most elegant/most sensible/safest way.
Any ideas for improvement?
char[] password = new char[50];
System.IO.StringReader reader = new System.IO.StringReader(this.textBoxPassword);
reader.Read(password, 0, 50);
byte[] bPassword = new byte[50];
for(int i = 0; i < 50; i++)
{
bPassword[i] = (byte)password[i]);
}
System.Security.Cryptography.SHA1 shaM = new System.Security.Cryptography.SHA1Managed();
byte[] hash = shaM.ComputeHash(bPassword);
char[] cHash = new char[hash.Length];
for(int i = 0; i < hash.Length; i++)
{
cHash[i] = (char)hash[i];
}
string hashword = new string(cHash);
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
You're right. It isn't the best way...
SHA1 shaM = new SHA1Managed();
UnicodeEncoding enc = new UnicodeEncoding();
byte[] original = enc.GetBytes(Text);
byte[] converted = shaM.ComputeHash(original);
Text = enc.GetString(converted);
The UnicodeEncoding class is in the System.Text namespace. I always do something that I think shouldn't take that much...then I find out how I could have saved myself a bunch of time and heartache by just looking for something in the FCL that would do it for me.
Oh, and you aren't supposed to create strings like this:
string hashword = new string(cHash); You should do it like this:
string hashword = cHash; Or, you should probably just use cHash instead of creating a new string.
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
Thanks very much I knew there had to be a better way!
P.S. What's wrong with using one of the string constructors to create a string?
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
I dunno. But Jeffery Richter says not to. So you know what I don't do? Use the String constructor. In Applied Microsoft .NET Framework Programming, page 253, he says:
"In C#, you can't use the new operator to construct a String object..."
Go figure...
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
David Stone wrote:
"In C#, you can't use the new operator to construct a String object..."
The code I gave does work as it should do so, can't is a bit misleading; shouldn't may have some merits, though.
David Stone wrote:
Jeffery Richter says not to
If Jeffrey says so, then I will cease this instant. I keep meaning to get the book or something similar, but haven't quite got round to it yet. I'm too busy blundering about unguided
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
AHHH. Damn and blast. David beat me to it.
Yeah, hes right. Yours isn't the best way of doing it.
public string test2(string strBoxPassword)
{
byte[] bPassword = System.Text.Encoding.Default.GetBytes(strBoxPassword);
System.Security.Cryptography.SHA1 shaM = new System.Security.Cryptography.SHA1Managed();
byte[] hash = shaM.ComputeHash(bPassword);
return System.Text.Encoding.Default.GetString(hash);
}
Note that this and Davids reply are pretty similar except he excplicitly speficies the Unicode encoder. However, please note that both these methods WILL NOT return the same hash as your old method. The reason beeing is that you hard code 50 characters in the source byte array no matter what the actual length is. Our methods only hash the actual contents of the data and no extra trailing bytes.
Therefore if you already have hashes in your DB based on the originial code your probably going to have to either stick with what you have or re generate all the hashes...
Pete
Insert Sig. Here!
|
|
|
|
|
Pete Bassett wrote:
AHHH. Damn and blast. David beat me to it.
It helps if you were working on the same bit of code for a personal project just about a week ago.
Pete Bassett wrote:
Note that this and Davids reply are pretty similar except he excplicitly speficies the Unicode encoder
Death to ASCII! Long Live Unicode! Actually, your method might take Unicode...I'm not sure...
[edit]Actually, your method gets the System's current encoding. So if your OS was based on Unicode(XP I think) then it'll get a Unicode encoder.[/edit]
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
David Stone wrote:
So if your OS was based on Unicode(XP I think) then it'll get a Unicode encoder
Wrong! Default encoder with actually return the current windows codepage. Dont ask me how, but I realised that working on my irc client. Very strange indeed. Best is just to use the same Encoder/Decoder, and not rely on different (but perhaps similar) ones.
"I dont have a life, I have a program."
|
|
|
|
|
Hope you don't mind my asking...but what the heck is a codepage?
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
David Stone wrote:
but what the heck is a codepage?
Not really sure either, but I think it is an extension to ASCII based on your system culture. Something along that path....
"I dont have a life, I have a program."
|
|
|
|
|
Found it!
http://www.microsoft.com/typography/unicode/cscp.htm[^]
In Windows 95 and NT, a codepage is a list of selected character codes in a certain order. Codepages are usually defined to support specific languages or groups of languages which share common writing systems. For example, codepage 1253 provides character codes required in the Greek writing system.
The order of the character codes in a codepage allows the system to provide the appropriate character code to an application when a user presses a key on the keyboard. When a new codepage is loaded, different character codes are provided to the application.
You will now find yourself in a wonderous, magical place, filled with talking gnomes, mythical squirrels, and, almost as an afterthought, your bookmarks
-Shog9 teaching Mel Feik how to bookmark
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
|
|
|
|
|
Thanks very much I knew there had to be a better way!
Derek Lakin.
I wish I was what I thought I was when I wished I was what I am.
Salamander Software Ltd.
|
|
|
|
|
I have my inherited form created and I have the controls set to be modifiable, setting them from Private to Protected. I also added the Main() logic so that all inherited forms can be selected as a starting form.
1) The documentation says I can compile to either a DLL or an EXE, I create a DLL and create reference to that DLL, yet when I create a new inherited form, it complains that the EXE does not exist. Do I have to create BOTH an EXE and DLL????
2) All of the stuff I've read indicates that I can create code in my base form and that code will be inherited in each instance. However when I create a new inherited form, it does not copy my [STAThread] code! I have yet to try creating control code, but I expect that that code would not copy either.
Any help on smoothing out these last two bumps is appreciated!!!
Thanks.
_____________________________________________
I have a tendancy to where my mind on my sleeve I have a habit of losing my shirt...
|
|
|
|
|
Anybody know how to go about getting a handle to the default windows cursor?
Cursors.Arrow.Handle returns what seems to be a valid handle, but I get an error when I call
InPtr Hicon = Cursors.Arrow.Handle;<br />
<br />
Bitmap tempBitmap = Bitmap.FromHicon(Hicon);
The error is "invalid parameter used"
\\winnt\cursors doesn't seem to contain the actual default arrow cursor as a ".cur" file. It's defined in winuser.h via MAKEINTRESOURCE(...) with the identifier IDC_ARROW.
I wouldn't mind going the unmanaged route. (I'm doing this in fact, but using a cursor in the \\winnt\cursors directory). But that's just a temp solution as I really want the default cursor. How would I define Win32's LoadImage(...) or indeed the LoadCursor(...) function with regards to the MAKEINTRESOURCE(...) call?
Gosh, what an ugly question eh?
ASP.NET can never fail as working with it is like fitting bras to supermodels - it's one pleasure after the next - David Wulff
|
|
|
|
|
Senkwe Chanda wrote:
InPtr Hicon = Cursors.Arrow.Handle;
This IntPtr is actually a WIN32 HCURSOR, not a WIN32 HICON, hence the error.
Back to real work : D-19.
|
|
|
|
|
Thanks .S.Rod. I'm used to using them interchangably via win32. Do you have any ideas on how I can get access to the handle for the default windows cursor? IDC_ARROW?
ASP.NET can never fail as working with it is like fitting bras to supermodels - it's one pleasure after the next - David Wulff
|
|
|
|
|
Senkwe Chanda wrote:
Do you have any ideas on how I can get access to the handle for the default windows cursor?
Doing Cursors.Arrow.Handle is the right code (internally it does a simple ::LoadCursor(IDC_CURSOR);
But, as I have already said, this call returns a HCURSOR.
What you were trying to do next is build a bitmap. That's a fine idea, but the API method you use expects an HICON, not an HCURSOR.
So you've got to find somewhere (either in the .NET API, or through WIN32) a way to convert the HCURSOR to an HICON. I guess that if that was only a matter of casting, this would not lead to an error.
What about lurking around Codeproject articles dealing with HCURSOR and HICON ?
Back to real work : D-19.
|
|
|
|