|
"MySite.Application" is what you're supposed to replace. If you read the documentation for the @Application element, the Inherits attribute is the namespace + class name. Whatever namespace you use for your code you must add before Application , as you've defined your class.
I still recommend you use the file itself. You still get IntelliSense and you can compile the entire site using the links I gave you. If it's a matter of protecting your code 1) a developer could easily use something like ildasm.exe or ".NET Reflector" or any other disassembler or decompiler to see your code, or 2) simply change the Inherits attribute to point to a different type if you're concerned about security (and remember that security through obscurity is no security at all).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks again Heath,
well "MySite" is the dummy website I have created and I dont see the namespace keyword in newly created website - "MySite"...What I have is one default page with declaration like "public partial class" enclosed by no namespace declaration thats why I have tried applying "Application" and "MySite.Application"...
Its great to hear security stuff and vulnerability of .NET from ildasm. Anyways let me cleary stat the problem.
problem:
Presently I have full fledged portal based web application running up and fine in VS2003. There I have my global.asax.cs which does some processing in global events and sets few variables of this class to name, "ConnectionString", "hostpath" and many more, so can easily be accessed in all pages by Classname.VariableName (global.ConnectionString)...And this application also does initliazation of 2-3 classes in global events..
So, I need to have 2 things in inline scripting i.e. writing all code in global.asax),
1) Setting public variables as I said for Connectionstring, so I don need to change code in all my pages which currently references them with "global.Variable" way
2) Inititalizing other classes from global events..
I think main problem is "Codebehind" attribute which is taken away in Whidbey, And I think what you are saying could be an workaround to my problem. If it works then my last question would be "Is it true that you cant have codebehind feature with global.asax which's being considered a great boon to ASP.NET against ASP?"
Look forward to hearing from you.
|
|
|
|
|
Things written below are with respect to "Whidbey"
So, I need to have 2 things in inline scripting i.e. writing all code in global.asax),
1) Setting public variables as I said for Connectionstring, so I don need to change code in all my pages which currently references them with "global.Variable" way
2) Inititalizing other classes from global events..
I think main problem is "Codebehind" attribute which is taken away in Whidbey, And I think what you are saying could be an workaround to my problem. If it works then my last question would be "Is it true that you cant have codebehind feature with global.asax which's being considered a great boon to ASP.NET against ASP?"
REgards.
MaulikCE
|
|
|
|
|
The default namespace for a file in C# (which works differently than VB.NET in this regard) is the combination of the root project namespace you can find in the Project properties plus any folders you define. Of course, in C# you can change the namespace regardless of the location or even the project root namespace, unlike VB.NET that combines these things in the same way but in a cummulative manner, meaning that you never repeat the root or parent namespace in a source file otherwise you'll get a much longer, practically doubled namespace!
"Code-behind" wasn't removed in Whidbey, it was redefined to use partial classes instead of the previous method, which was multiple inheritence. The page (.aspx file) inheritted from the code-behind class, which inheritted from the Page class. Scary, and an unnecessary burden on the CLR.
Both goals could be solved by using another class, perhaps called Globals (seems to be common), rather than overloading the HttpApplication class unnecessarily. Since any changes to Web.config for the application (in the application root) or certain other events will tear down the AppDomain, you must make sure you re-initialize your properties correctly. Pretty much any way you do it will work.
If you don't need global.asax don't use it. This wasn't nearly used as much as originally intended (I gather) which is probably why it was removed from the default project files.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi all
I am C# programmer.. For my project i want to create a textbox like in Mspaint,which restrict the entering of characters upon reaching the Size.
I tried with MeasureString.. But not works
Pls tell if anyone knows how to do it..
Warm regards
Krishnan
If u can Dream... U can do it
|
|
|
|
|
MeasureString is graphics, which is why it's defined on the Graphics class. To limit text in a TextBox , you can post-validate the control (which fires when the focus is lost for that control) by handling the Validating event. If you want to limit which characters will even work, override the IsInputChar method for the TextBox :
public class NumericTextBox : TextBox
{
protected override bool IsInputChar(char charCode)
{
return charCode >= '0' &&charCode <= '9';
}
}
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
In my case i want to know how many charcaters can be enter in the textbox . How it can be know. So when reaching that number i can disable entering characters..
The problem here is to find the number of characters that can be enter in the text box (No scrolls)..
What u think ?
Regards
Krishnan
If u can Dream... U can do it
|
|
|
|
|
The MaxLength property of the TextBox lets you set a maximum number of characters that the user can enter, no matter the width (it can be 10 m's or 10 i's).
But if you set the TextBox to be, say, 100 pixels wide, and you want only 100 pixels of letters, be it 5 m's or 8 i's, it's a bit more difficult. As an option, try using the MaxLength property and making the TextBox wide enough.
But if you absolutely need to allow only a certain width of characters, try getting the font of the control, and using some graphics function (MeasureString could be, I am no expert.) to measure the current contents plus the new character in the KeyDown event, and if the new text is wider than the control, don't accept the key.
I hope to have given you some pointers. Good luck!
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hey, for some reason I'm having trouble trying to figure out what the best practice would be for my situation. Let me explain my situation and then I'll explain where I'm stuck. I'm creating a skinning engine, somewhat like Winamps. It uses xml as the "scripting language", I then parse the xml into objects. Heres a simple XML of what a script might look like...
<code>
<pre> <skin_info>
<name>acDesk Default Skin</name>
<version>1.0</version>
...........
</skin_info>
<element id="main_window" source="main_window.xml" />
..............
<element id="tab_strip" source="tab_strip.xml" /></pre>
</code>
I would then parse the skin.xml into an object called SkinDocument wich has all the info in the skin_info node and a collection of SkinElement objects defined by the element tags. The SkinElement then looks at the source file of the element and parses that into SkinComponents (layers, buttons, etc..).. heres what an element source file looks like...
<code>
<pre><!-- Set the properties for this window -->
<setproperty id="folder_path" value="main_window" />
<setproperty id="size" value="205,437" />
<setproperty id="minsize" value="205,437" />
<setproperty id="transkey" value="255,0,255" />
<!-- Create the border layers -->
<layer id="top"
location="0,0"
width="$WIN_WIDTH"
height="5"
image="top_bar.png" /> <!-- This is a SkinComponent -->
<layer id="left"
location="0,0"
width="5"
height="$WIN_HEIGHT"
image="left_bar.png" />
<layer id="right"
location="0,compute($WIN_WIDTH - 5)"
width="5"
height="$WIN_HEIGHT"
image="right_bar.png" />
............
<!-- Create the title bar buttons container -->
<container id="title_buttons" location="compute($WIN_WIDTH - {$WIDTH}), 5" width="autosize-left" height="autosize-down" padding="5">
<button id="close_button"
width="10"
height="10"
action="CLOSE"
toolTip="Close acDesk"
image_strip="close_button.png" />
<button id="minimize_button"
width="10"
height="10"
action="MINIMIZE"
toolTip="Minimize acDesk"
image_strip="minimize_button.png" />
</container>
<!-- Create the content container -->
<container id="content"
location="5,5"
width="compute($WIN_WIDTH - 5)"
height="compute($WIN_HEIGHT - 5)"
padding="0"
source="$WORKSPACE" />
............</pre>
</code>
So, now theres a little background of what I'm doing. And heres my issue.. I'm going to be creating a UI to work around these objects, IE: SkinForm, SkinProgressBar, SkinPanel, etc.. So I need these objects to be exposed only internally, BUT anyone using this component will need the ability to "hot-swap" skins. They might not have access to the internal library to access these objects. So this forces me to make most of them public. My problem with this is that I don't want users to be able to "screw" with the skin. I don't know what some people might do, and I don't wanna even give them the chance to add SkinElements, SkinComponents, etc... at run time. So what I'm thinking of doing is creating another object called SkinManager wich will act as a wrapper for these objects. Then make all the other objects internal only. The SkinManager would contain only static fields so that it could be accessed across a whole application without having a crap load of instaces being created and alot of parsing going on. My question to everyone is what is the best practice here? Should I make all the object public and trust the user won't mess with the skin at runtime and trust they will create their own manager so that they aren't parsing everytime a skin UI object is loaded, or should I go with the SkinManager idea? Maybe both? Any help is appreciated! Thanks in advance!!!
BTW: This is going be under the GPL license, so anything I do will prolly be changed and made better down the road by someone else
|
|
|
|
|
Ignore those <pre> tags.. I was trying to get the forums to show the xml as code, but yet still allow the use of < and > for html code (ie: <code>)
|
|
|
|
|
|
I'm not using XML Serialization. The only reason I'm not is I don't wanna force skin developers to use a skin creation tool created in .net. I myself perfer to make skins by hand.. I don't use any program to make winamp skins and such, so thats the avenue I'm taking. With that in mind, I think I have decided I'm going to go down both paths. I'm going to make all objects public, but I'm also going to provide a SkinManager class so that there is a global class that can be used to manage the current skin. This will cut down on senseless parsing of the skin xml files and will hopefully make it much faster. My skin objects will all reference the SkinManager object. So I will insure that there is one created. I'm still up for other suggestions tho, so if someone out there has some good ideas on what I should do, that'd be great
|
|
|
|
|
Just because you use XML Serialization doesn't mean that other applications have to use XML Serialization (which isn't limited to .NET; Java has it too, and other platforms do too, I'm sure). XML is XML - plain and simple. It could be generated through some sort of XML Serialization, output as text from an XML writer or even from a plain text writer, or even generated by hand. Doesn't matter, and that's part of the beauty of XML and why legacy systems can support it relatively easy. The data is agnostic to how it's written or loaded.
leppie's suggestion is the common way to do this in .NET because it aleviates the burden of creating objects from XML rather easily, but creating skins doesn't have to be done in .NET.
I suggest searching for "skinning" on this site using the text box below the logo on every page, or even just the 'net. There's a lot of examples - both for .NET and not - that you could learn a lot from.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I have done that, and Its not a matter of actually doing the skinning, I can do that.. its the actual skin objects. And I am aware of the versitility of XML also. When I was talking about Serialization I was talking about the actual serializing/deserializing of my objects. I'm fairly new to this XML stuff with C#. The most work I've done with XML in C# is just DataSets, DataTables, etc.. I do remember reading somewhere about what you're talking about, but I cannot remember where. Maybe you can elaborate a bit on what you mean?
|
|
|
|
|
What I spoke of about XML is generic - nay, essential - to XML. I recommend you read http://www.w3.org/XML/[^].
You should also practice the use of namespaces, which allow you to scope your elements and, optionally, your attributes similar to how methods and properties are defined for different types. This allows your skins to be extended for custom controls, for example.
If you want a primer to XML in .NET, read Employing XML in the .NET Framework[^] in the .NET Framework SDK.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
aye.. that MSDN article is more along the lines of what i need.. I do understand how to use namspaces and all that stuff, thats not the problem. I have a really hard time expressing my ideas on paper, even tho they make perfect sense in my head, so please bare with me Basically, what I'd ideally like to do is take one of my objects, say SkinElement.. point it to a xml file, have it read that file and fill properties, execute methods, etc.. I just went out this morning and bought "Beginning C# XML" - Wrox Press. After a quick look at the book, I noticed some stuff with Serialization. Using attributes on members to "link" them to the xml file. IE: [XmlAttribute] [XmlElement] etc.. Now, this only talks about the actual serialization of the object. It dosen't really talk about "deserializing" an xml file into the object. Is that possible? Because that would be ideal as it would cut down on alot of parsing
|
|
|
|
|
"Serialization" typically implies "deserialization" as well, since the two go hand in hand. If you read the documentation I linked, XML deserialization requires you to implement a public default constructor (no parameters) and use the XmlSerializer.Deserialize method.
Again, search for examples of what you're trying to do here on Code Project. They do exist, and one such implementation (though it's not skinning, but actual form layout and event hook-ups in much the same way) is called "MyXaml".
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
I made a simple application (win app) like wordpad,
when user save information from my app, it will create a new file format (*.abc for example), I would like to register an icon for this new file format
Anyway, when I double_click to this file (*.abc) in window Explorer, my app will automatically open and use this file as usual
Show me how to solve this.
Thankz!
|
|
|
|
|
Read Creating a File Association[^] in the MSDN Library. This is typically the job of an installer, and if you use the Windows Installer project in Visual Studio you can do this easily by following the instructions in File Types Management in Deployment[^].
Some applications will conditionally or unconditionally associate file types when the application starts or options are changed. Media players are a good example of conditionally associate file types with an icon (and, more importantly, their application) because common file types (.mp3, .wav, etc.) can be played by multiple players. The more friendly players allow you to select which extensions are handled and whether or not to enforce those while the application is running. It really depends on whether or not you expect other editors to be able to handle your file type.
To do that, you need to follow the instructions in the first link using the Microsoft.Win32.Registry and Microosft.Win32.RegistryKey classes.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
basically, I want to add the url history of ie, each one onto a new line. here's the code I have written thus far. I am druly bedazzled as to why it won't work. thanks for the help. ps, if you know a better way to add the registry values (all that exist in the registry key) onto new lines in a multiline textbox, that is much simpler than my confusing integers way (the rookie way!) of doing it, please let me know. I don't like being ignorant. anyways, thanks and here's the code:
[CODE]
RegistryKey home_page_open = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\Main");
this.textBox3.Text = home_page_open.GetValue("Start Page").ToString();
//load history into textbox
RegistryKey history = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Internet Explorer\TypedURLs");
int repeat = history.SubKeyCount;
int init = 1;
while (repeat > 0)
{
textBox4.Text += "\r\n" + history.GetValue("url" + init.ToString()).ToString();
init ++;
repeat --;
}
[/CODE]
|
|
|
|
|
pyrojoe wrote:
int repeat = history.SubKeyCount
SubKeyCount won't get you the number of URL values, you need ValueCount . A SubKey, as you might guess from other code you've got, is the directory-like path to get to the values you are looking for.
Also, your loop is a little crazy, you need to learn about for loops. I suggest changing your loop to:
int count = history.ValueCount;
for(int i = 1; i<=count; i++)
{
}
Does this help?
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|
|
|
hello,
i made a program that contains serveral dll's that are included. But when i distribute my program the client mustn’t see the dll's just a package that contains the dll but is encrypte or something like that. Is this possible??
greetings
Sander
|
|
|
|
|
Gedrain wrote:
when i distribute my program the client mustn’t see the dll's
If the client is paying you money to create these DLLs why shouldn't they be able to see them?
There are tools that will make the .NET assemblies difficult to reverse engineer. Dotfuscator Community Edition is included with Visual Studio, which is a cut down version so you may like to buy the full version if it is not secure enough for you.
Do you want to know more?
WDevs.com - Open Source Code Hosting, Blogs, FTP, Mail and Forums
|
|
|
|
|