|
Hi there,
I am using .NET 2.0 with C#.
When I create a new master page, the following namespaces are added automatically:
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;
And then the other necessary code:
public partial class App_MasterPages_Website : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
Are all those namespaces required?? What would be best, to remove them all except using System; and add just the necessary namepaces as what I need them?? I see the same namespaces are included when I add a new web page.
The reason why I am asking is because I want to keep my code as clean as possible.
Please can someone advise me?
Regards
ma se
|
|
|
|
|
ma se wrote: Are all those namespaces required??
No.
ma se wrote: What would be best, to remove them all except using System; and add just the necessary namepaces as what I need them??
Sounds like a good plan.
ma se wrote: The reason why I am asking is because I want to keep my code as clean as possible.
Please can someone advise me?
Yes. Keep your code as clean as possible.
|
|
|
|
|
|
It's a matter of taste. Most of them are not required, but a using statement doesn't add anything to the generated code, so they don't do any harm either.
Actually none of them are strictly required, so you can remove all of them if you like, but then you have to specify the namespace for all classes that you use, like for example System.EventArgs.
I usually remove the ones I rarely use and leave the ones that I regularly use, and end up with:
using System;<br />
using System.Collections.Generic;<br />
using System.Web;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
using System.Web.UI.HtmlControls;
---
single minded; short sighted; long gone;
|
|
|
|
|
|
Hi Guffa,
When you say the using statement doesn't add anything to the generated code, then what does it do? Is it just a reference?
Regards
ma se
|
|
|
|
|
It's not even a reference. It's just a declaration that you want to be able to access the members of the namespace directly, without having to specify the full namespace.
The using statement requires that there is a reference to the dll that contains the namespace, but the statement itself only makes the namespace avialable.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi there,
I am using .NET 2.0 with C#.
I have a website project. I also have a master page in the root directory called Website.master. In the “code behind” of this master file I have the following namespace MyNamespace.Master. When I view the object browser I don’t see this namespace there. Why is this?? Visual Studio only seems to add the namespaces that are in the Bin and App_Code folders. I don’t know if I’m not viewing it correctly, but I can not see it there.
Please can some one help me?
Regards
ma se
|
|
|
|
|
I wanna know how to add an item to a combobox from a textbox by clicking a button.
I usually use C# so i'd prefer to finish what i'm doing in C#.
thanx.
|
|
|
|
|
Try something like:
comboBox1.Items.Add(textBox1.Text);
|
|
|
|
|
|
that worked but when i open the program i add an item, if i restart the program the new item isn't there anymore...
|
|
|
|
|
There may be other ways, but here's what I would do:
- Create a Serializable class with an array of strings as a member.
- When you close your application, create an instance of this class and copy your comboBox items into the string array of your class.
- Then, serialize your class in to file.
Finally, when you start your application, deserialize your class, and use
comboBox1.Items.Clear();<br />
comboBox1.Items.AddRange(myCustomClassInstance.StringArray);
You will find plenty of information and tutorials about serialization on the web.
Cheers
|
|
|
|
|
Won't
myNiftyComboBox.Items.Add(myVerySpecialTextBox.Text);
do the trick?
Regards,
Matt
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
|
In my window application form i use two mdi form .
Every mdi form contain 3 children form.Is this possible if i call one mdi form into the other mdi form.If this possible how i call the other mdi form
life is so sweet
|
|
|
|
|
|
Hello,
I have a WebBrowswer control in my application and I can do a SendKeys.Send("^f") to open the Find dialog in the window. This is nifty enough.
What I'd like to do is populate that textbox widget on the Find dialog with a string of my choosing, but frankly I'm not sure where to start on this. As I've got the text - via some processing in my application that is likely the text the user will want to search for, I'd like to populate it without having the user fat finger it in.
Any ideas?
Thanks much,
Matt
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
So, I solved it myself.
Clipboard.SetText(theTextString);
will set the desired text in the clipboard. The somewhat cheesy solution for the paste was to do:
timer1.Start();
and in the time1_Tick handler, do:
SendKeys.Send("^v");
Not necessarily elegant, but it did the trick.
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
how i can enter the values in my database using datagrid ???
life is so sweet
|
|
|
|
|
There are lot of article for doing so one of them is http://www.codeproject.com/aspnet/EditGrid.asp
Google it and you will find many !!!
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
Hi,
i've created a user control and it must read an app.config, but it doesn't work.
The user control can'f find the app.config file.
how I do to user control find thee app.config file?
thank you.
|
|
|
|
|
Controls and .DLL's don't get their own configuration files. As the name suggests, they're Application configuration files, not component. You're control will have to rely on the developer supplying the configuration in his/her application's app.config file if you want to use the .NET Frameworks built-in classes and methods for retrieving config options.
The only way to supply a seperate config file for your component (not a good idea BTW!), is to implement your own config file (preferrably in XML,) specifying your own schema and writing the code to find and load the config file yourself.
Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic 2006, 2007
|
|
|
|
|
is it possible the dll read the app.config file of the application?
|
|
|
|
|
How can we combine a transparent GIF image with a JPG file and save the resulting image in disc.
I want the GIF to act as a frame that we can see the JPG image through it .
|
|
|
|