|
I can think of two ways to do this. I think you can subscribe to the BeginRequest and EndRequest events on the Global.asax. Also, I think you can grab the current context and get the Timestamp property. It's the timestamp of the initial request. Then you can add a handler for PreRender and write the page loading time into the page just before it gets sent back to the user. These are just ideas though, I'm not sure if that's the best way to do it.
Logifusion[^]
|
|
|
|
|
I’m about to create an options dialog that will be opened from my windows application main Forms menu.
I have many different “modules” in the application which each of them need to have an own options dialog. For sure this is a common situation.
I need some kind of “pattern” to create an Options dialog and add the other modules option dialogs in a tab-like way.
All tips of how I can do that in a clean way are welcomed!!
My next thing is to store all these settings (properties) in some kind of file and then restore the settings when my application runs next time. I’ve tried searched some articles but I really don’t know what to search on…
_____________________________
...and justice for all
APe
|
|
|
|
|
I have a very similar situation. I'll try to outline what I did:
1. Every module has a class implementing my IModule interface.
2. The IModule interface contains a method like OptionsControlBase[] GetOptionsControl() .
3. OptionsControlBase is simply an empty user control defining the following functions:
public abstract void ApplyChanges();
public abstract void UpdateOptions();
public abstract string Name { get; }
...
4. Now when the options dialog is opened it iterates through all modules, asks those for the options controls and generates one tab on the fly for each of them. The name of the tab is just what is returned by the Name property and the whole options control is docked with fill into the tab. Also one call to
UpdateOptions is done for each.
5. UpdateOptions implements the logic for filling the options control with the current application settings. Thus if you need some kind of reset button on the options form just call this one again on each control.
6. ApplyChanges gets called on every options control when the user clicks 'Ok' or 'Apply' on the options form. It contains the logic to apply the settings within the option controls to the application settings.
Everything clear?
To store and load these settings just add more functions (like GetSettings and SetSettings ) to your modules. Then when you want to load or save all application settings just iterate over the list of modules and call those functions on each of them.
|
|
|
|
|
hi,
I am new to c#, can any one help me how to get the position of the text from a text box and use them as a data.
for eg:
let input on the textbox be 10,20
i need to place that 10 to X and 20 to Y .
Thankyou,
Regards
Praveen
|
|
|
|
|
Use method Split.
for example :
this.textbox.Text = "10,20";
string[] mystring = this.textbox.Text.Split(',');
mystring[0] is 10
mystring[1] is 20
|
|
|
|
|
Hi! I would like to know if it´s possible to make a class object global.
Just like if I declared once, and a lot of classes can work with it, keeping the same values.
Because if I instantiate an object for every class... the values go blank =/ (Class obj = new Class())
Thnx
|
|
|
|
|
Hi,
make function and property as static so that you can call from anywhere without creating instance
-- modified at 6:39 Friday 7th July, 2006
|
|
|
|
|
Yeah something like:
public static decimal ComputeInterest()
{
// Code here
}
|
|
|
|
|
If you actually need an object instead of just static methods in a class, you can make a singleton:
public class Singleton {
private Singleton instance;
private Singleton() {}
public Singletton GetInstance() {
if (this.instance == null) {
this.instance = new Singleton();
}
return this.instance;
}
}
---
b { font-weight: normal; }>
|
|
|
|
|
private static Singleton instance;
public static Singletton GetInstance();
might though. Also, I read once, that private static Singleton instance = new Singleton(); would be gauranteed to be accessed in order and is not subject to threading issues. Whereas this.instance == null can cause threading problems.
A man said to the universe:
"Sir I exist!"
"However," replied the Universe, "The fact has not created in me A sense of obligation."
-- Stephen Crane
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: private static Singleton instance;
public static Singletton GetInstance();
might though.
Yes, correct.
Ennis Ray Lynch, Jr. wrote: Whereas this.instance == null can cause threading problems.
Yes, to make it thread safe you need locking.
---
b { font-weight: normal; }
|
|
|
|
|
How can i change programaticaly the position of the caret in a RichTextBoxControl ?
|
|
|
|
|
Use RichTextBox.Select() and RichTextBox.ScrollToCaret() .
Regards,
mav
--
Black holes are the places where god divided by 0...
|
|
|
|
|
or RichTextBox.SelectionStart and RichTextBox.SelectionLength ...
If you just want to move the cursor, leave RichTextBox.SelectionLength = 0.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
Hi,
Why when using this method is there no paramter size property to set? And does the method indicate that it is an input parameter?
Regards,
ma se
|
|
|
|
|
The size is implied by the DbType or calculated when necessary. That's the great thing about these blocks, it takes of the little things for you and allows you to concentrate on the solution.
Yes, as the name implies, this is for setting Input parameters. There is a cooresponding AddOutParameter and a simple AddParamater if you need more control.
|
|
|
|
|
Hi,
I am using the data access application block January 2006. It's the first time that I am using it. Can someone please look at my code and comment on it, I want to know if I am doing this correctly, and if there is anything I need to add or to close/dispose. Am I checking for the correct exceptions? Basically I want to return a strongly typed list of Vendor objects:
public static List<Vendor> GetAllVendors()
{
DbCommand dbCommand = null;
List<Vendor> vendorList = new List<Vendor>();
try
{
// Load the default database
Database db = DatabaseHelper.DatabaseDB;
// Specify the stored procedure
string strSProc = "sp_Vendor_GetAllVendors";
using (dbCommand = db.GetStoredProcCommand(strSProc))
{
IDataReader rdr = db.ExecuteReader(dbCommand);
while (rdr.Read())
{
Vendor objVendor = new Vendor();
objVendor.ID = DatabaseHelper.GetInt(rdr["VendorID_PK"]);
objVendor.Status = DatabaseHelper.GetBool(rdr["VendorStatus"]);
// Add Vendor instance to array
vendorList.Add(objVendor);
}
rdr.Close();
}
}
catch (SqlException ex)
{
throw new Exception(ex.Message, ex);
}
finally
{
dbCommand.Dispose();
}
return vendorList;
}
Hope someone can let me know!
Regards,
ma se
|
|
|
|
|
Nothing major that I can see.
Although there is nothing wrong with calling dbCommand.Dispose in the finally block it is technically unnecessary as it will be disposed when the using block is exited.
I would also consider using DataTable.Load(db.ExecuteReader). That way you could close the db connection sooner and still iterate through the resultset.
DataTable dt = new DataTable();
dt.Load(db.ExecuteReader(dbCommand));
// Close connection here
DataTableReader reader = dt.CreateDataReader();
while(reader.Reader())...
|
|
|
|
|
Hi Coders
I am using a webbrowser control in my winform application. I want to open all the links in the same window even though if the link is having the target=_blank property also.
Its very urget. Please help me out.
Oohmesh
|
|
|
|
|
You need to add event handlers to handle "NewWindow" event when the user clicks on a link with the target not on the current webbrowser
1. For Pre Windows XP SP2
axWebBrowser.NewWindow2
2. For Windows XP2 and later there is another event named
axWebBrowser.NewWindow3
The whole code for this would look
axWebBrowser.NewWindow2 += new AxSHDocVw.DWebBrowserEvents2_NewWindow2EventHandler(axWebBrowser_NewWindow2);<br />
<br />
try<br />
{<br />
axWebBrowser.NewWindow3 += new AxSHDocVw.DWebBrowserEvents2_NewWindow3EventHandler(axWebBrowser_NewWindow3);<br />
}<br />
catch ( Exception )<br />
{<br />
}
Now in the event handlers all you have to do is block the new window from opening by putting
e.Cancel = true;
and redirect the current webbrowser to the new URL sent by the event.
See more at NewWindow3[^]
Jup
|
|
|
|
|
Where i ll find this "axWebBrowser" class...Pls send the namespace.
Aur it's an coponent u r using...
Anuj
|
|
|
|
|
That's the variable name. The activeX browser could be found on your system. With .NET 1.1 the simplest way is that you should import that COM component from system32/shdocvw.dll. .NET 2.0 already have a web browser control for you by default from the toolbox.
-Good Luck
Jup
|
|
|
|
|
I need code to do the following in C#-
1. To display - The table of content from a pdf file in a pane on the left
side of the window
2. On clicking a topic in the table of content - It should diplay the
topic in a pane on the right side of the window.
Regards,
Prati
-- modified at 5:32 Friday 7th July, 2006
|
|
|
|
|
How to add text objects and others at run time. How to sort the fileds in report, choice of sorting field will be read from user.
Jey
|
|
|
|
|
hi all,
Sorry for posting this problem in the C# section aswell...
its just that i have been getting GREAT reply in the C# section
i have a xsl/xml Question.
<href>http://www.codeproject.com/script/comments/forums.asp?forumid=3421&select=1565540&df=100#xx1565540xx
He who laughs last...
|
|
|
|