Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
C

Craig G Fraser

@Craig G Fraser
About
Posts
42
Topics
11
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Getting the page height
    C Craig G Fraser

    The method to get the height differs depending in what browser you are using. I have a javascript function that i use to center an element on a screen. This determines the browser being used and uses the correct method accordingly. Hope this helps.

    // centers an element on the screen
    function centerElement(element, left, top)
    {
    var x = document.body.scrollWidth;
    var y = document.body.scrollHeight;
    if (getBrowser().indexOf('IE') == 0)
    {
    x = document.documentElement.clientWidth;
    y = document.documentElement.clientHeight;
    }
    x = (x / 2) + document.body.scrollLeft - (element.offsetWidth / 2);
    y = (y / 2) + document.body.scrollTop - (element.offsetHeight / 2);
    if (arguments.length < 2) left = true;
    if (left) element.style.left = x + 'px';
    if (arguments.length < 3) top = true;
    if (top) element.style.top = y + 'px';
    }

    // method to determine the browser for browser-specific javascript.
    // Currently returns a string with possible values IE6, IE7, Firefox, Other
    function getBrowser()
    {
    if (navigator.appName == 'Microsoft Internet Explorer')
    {
    return 'IE' + parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]);
    }
    else if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1)
    {
    return 'Firefox';
    }

    return 'Other';
    

    }

    Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    Web Development csharp asp-net

  • Need to access value from app.config file
    C Craig G Fraser

    Try this: Properties.Settings set = Properties.Settings.Default; string str = set.DatabasePath; return str; or simply return Properties.Settings.Default.DatabasePath;

    Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    C# question

  • Best cellphone?
    C Craig G Fraser

    Nokia N73.....Personally I would stick with Nokia and stay away from Samsung... http://www.nokia.com/nseries/index.html[^] Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    The Lounge c++ com linux architecture performance

  • Visual Source Safe
    C Craig G Fraser

    Subversion is the way to go. We have migrated from VSS and have no regrets. We alsouse the Ank plugin for VS2005....not very stable though...so mostly do all the checking in/updating from explorer using Tortoise. Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    The Lounge question discussion

  • Custom software development
    C Craig G Fraser

    Oops...a huge understatement :) I lost a 300gig HD....Source Code,DVD's,CD's etc... Thought i was going to die :( Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    The Lounge database sql-server sysadmin sales question

  • Custom software development
    C Craig G Fraser

    I have written a commercial application which started out as a request from a company to write them the application. The app was sold to them initially but over time i have made the application more generic so that it fits the requirements of other companies within the same market/industry. I have since solde to a further 2 companies. My initial sale of the software was a once off payment but becuase the application now requires quite a bit of support and enhancements, i am charging them a monthll licence and support fee. So to answer your 3 questions (In my opinion) - The cost of the app depends on its complexity and time it will take you to write it. - It depends on what agreement you have with the company. I have written a product for a company where they insisted on owning the IP (intellectual Property) and the source code in which case i cannot sell to anyone else. This is mainly because the application is based on company sensitive formulease etc...I have another application where i own the IP and source code and can sell to whoever i want. - Dont give them source code unless its part of the agreement as mentioned above.Remember, as long as you own the source code, you are the only person who can make any future enhancements....so you can secure future income... Just make sure you backup..backup..backup...the source in a few place to keep it safe ! I've lost mine once...very big mistake ! Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    The Lounge database sql-server sysadmin sales question

  • Quick Poll
    C Craig G Fraser

    Golf, Rugby and Cricket Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    The Lounge question

  • Best UI Suite ? [modified]
    C Craig G Fraser

    Web Apps: Infragistics suite is the best that I have used. We did a lot of evaluations last year and decided to go with IG....with no regrets. The one reson we never went for Dev Express for our Web Apps was that their web grid control didnt have the heirarchial functionality that IG has. Win Apps: Dev Express. Again, after a lot of evaluation we decide to use Dev Express for one of our Win products. They are very eay to use and provide a rich UI experience. The ability to change skin/themes on the fly was also a big plus, enabling users to customise their own look and feel. Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    The Lounge c++ design question

  • could everyone show me the way to change CType in VB.NET to C#?
    C Craig G Fraser

    Are you using masterpages ?? If you are then the controls id will not be "lblCompanyName"...it will be something like "ctl00_Main_lblCompanyName"...which is prefixed by the content placeholders id....so you should use the following code. Label lb=(Label)dgItem.FindControl(this.lblCompanyName.ClientID); Response.Write(lb.Text); This may help..possibly Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    C# csharp sysadmin question

  • Database Synchronisation
    C Craig G Fraser

    Hi, I have an c#.net windows app that runs on client laptops with a MS Access database sitting on a server. Sometimes the users need to work on the system on the road so I need to create a local copy of the database on theie laptops. Obviously I need to synchronise the databases when they plug back into the server....I guess my question is, does anyone know of a 3rd party product/tool that will handle all this for me (preferably free...or cheap). I could try and write my own code but was hoping to save time by using an existing product....Any ideas would be greatly appreciated. Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    C# csharp database sysadmin question

  • Returning Multiple Tables from Stored Procedure
    C Craig G Fraser

    Hi, Does anyone know how to return muliple tables from a stored procedure to an .Net Application. For example if my sp has 3 separate select statements I want to return a dataset containing 3 tables with the results of the 3 select statements. Any help would be greatly appreciated. Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    Database tutorial csharp sharepoint database help

  • Worldwide Internet Access Speeds
    C Craig G Fraser

    Hey Paul, good to hear from a fellow saffa... I absolutely agree...I lived in UK for 8.5 years and have seen their speeds steadily increase and the prices steadily decrease whilst we have to bend over and take it from Telkom....check out http://www.hellkom.co.za/ quiet good for a laugh... I think that wireless is going to take off faster here and prices are already comparible to fixe line...although i was shocked to hear the other day that Sentech (one of 2 wireless providers) is 100% governmnet owned....hmmm Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    The Lounge performance

  • Worldwide Internet Access Speeds
    C Craig G Fraser

    Hi, I am curious to hear from you guys in other countries around the world about your internet access speeds and the costs thereof. I am from South Africa and believe me when it comes to speed and affordability...we are living in the dark ages...I think its a result of years and years of our telecoms provider monopoly. Anyway...for an ADSL connection we pay +- USD70.00 for a 512mb download which is also capped at 1gig per month...when you hit the cap, the spead is reverted back to dialup speed...shocking isnt it !!! Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    The Lounge performance

  • ASP.NET 2.0 - Wizard Control Steps Problem
    C Craig G Fraser

    Hi, Does anyone know how to hide/show wizard steps dynamically from within code. I want to be able to keep the left toolbar visible and only show steps that are relevant to a specific user (eg: based on security). I have created the wizard control with ALL the steps on but cannot hide them. I also tried adding steps dynamically but the dynamically added steps aren't retained in the viewstate. if you reload the step on page load, you will not be able to get the value from the textboxes because of the page lifecycle. Any ideas on this one. Any help will be much appreciated. Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    ASP.NET help csharp asp-net security tutorial

  • Dam virus
    C Craig G Fraser

    I had the exact same thing happen to me on my laptop. It was the letter "T" which kept repeating itself without being pressed. Then sometimes it works fine and then the problem re-appears. I eventually changed my keyboard and the problem was sorted out - so i would say that it is a more likely a hardware problem. Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    The Lounge tutorial

  • Converting decimal to String
    C Craig G Fraser

    Instead of this:-

    Subrahmanyam K wrote:

    decimal d = 45.52 lblNetPrice.Text = Convert.ToString(d);

    try this:- decimal d = 45.52 lblNetPrice.Text = d.ToString("###,##0.00") Cheers, Craig ** I'd rather try and fail than fail to try ;) **

    C# question

  • A True Global Class?
    C Craig G Fraser

    I use a class to hold all my "global" settings which i load on application startup. These values are accessable from anywhere in the app. Heres how you do it: 1) Create a class which is public 2) Add public static variables where you will store your settings. public class Globals { public static bool bBoolvalue; public static string sStringValue; public Globals() { } } 3) Then when you app starts up - just assign values to these variables eg: Globals.sStringValue = "This is a string"; 4) This variable will now contain the assigned value and because it is public static you will be able to reference it from anywhere in your app eg: string sTest = Globals.sStringValue; Hope this helps, Cheers Craig ** I'd rather try and fail than fail to try **

    C# csharp question

  • Textbox
    C Craig G Fraser

    A Simple way is to use the textbox's KeyPress Event. Check for the key pressed and if it is not a valid key then cancel the event (e.cancel) which will cause the key value not to be displayed. The code below is an example of the KeyPress event for a textbox that only allows Numerics. Hope this helps, Craig private void txtValue_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e) { string s = "0123456789" + (char)8 + (char)9 ; if (s.IndexOf(e.KeyChar.ToString().ToUpper(),0) ==-1) { e.Handled = true; return; } }

    C# question

  • Direct Crystal Printing to LPT port - Please Help
    C Craig G Fraser

    Hi Heath, Thanx for the info....had a look and boy that stuff is really confusing for me....Havent worked with calls to unmaganged code before so struggling to get my head around it and how to implement it in my code. I have managed to sort out the problem by creating a class using System.Management functionality.....Not sure if this is the best way but it works so will do for now....Does my class below look ok or do you tink it will cause problems ? You really helped me to solve this so thanx a million...it really is appreciated.. Cheers Craig using System; using System.Management; using System.Collections; namespace VTG.Functions { public class PrintFunctions { public struct PrinterInfo { public string sPrinterName; public bool bShared; public string sSharedName; public string sServerName; public string sPortName; public bool bDefaultPrinter; } public static PrinterInfo[] GetPrintersCollection() { PrinterInfo[] pi = new PrinterInfo[10]; string searchQuery = "SELECT * FROM Win32_Printer"; ManagementObjectSearcher searchPrinters = new ManagementObjectSearcher(searchQuery); ManagementObjectCollection printerCollection = searchPrinters.Get(); int iPrinterIndex=0; foreach(ManagementObject printer in printerCollection) { pi[iPrinterIndex].sPrinterName=printer.Properties["Name"].Value.ToString(); pi[iPrinterIndex].bShared=Convert.ToBoolean(printer.Properties["Shared"].Value); if (pi[iPrinterIndex].bShared==true) { pi[iPrinterIndex].sSharedName=printer.Properties["ShareName"].Value.ToString(); pi[iPrinterIndex].sServerName=printer.Properties["ServerName"].Value.ToString(); } pi[iPrinterIndex].sPortName=printer.Properties["PortName"].Value.ToString(); pi[iPrinterIndex].bDefaultPrinter=Convert.ToBoolean(printer.Properties["Default"].Value); iPrinterIndex++; } return pi; } } }

    C# sysadmin help tutorial

  • Direct Crystal Printing to LPT port - Please Help
    C Craig G Fraser

    Excellent..that sounds like the answer. In my app i had the LPT ports configurable in my app.config so i'll just change this to hold the printer name instead as you have suggested.

    Heath Stewart wrote:

    If you want to find out the printer name on a specific LPT port, you could P/Invoke EnumPrinters http://msdn.microsoft.com/library/en-us/gdi/prntspol\_9fjn.asp\[^\] and enumerate the printers till you find one installed on LPTx: (keeping in mind that a printer can be on more than one LPT port, so in that case a comma-delimited list is returned so be sure to parse that as well).

    Any chane you point me to some sample code that retrieves the printer names as mentioned above...I had a look at the link you sent but i'm afraid having not worked in this area a lot, it doesnt really make too much sense to me. Craigo

    C# sysadmin help tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups