Posted by: lornecjones | April 20, 2010

WOW Volcano Pictures

http://www.telegraph.co.uk/earth/earthpicturegalleries/7606679/Iceland-volcano-the-latest-spectacular-pictures-of-the-volcanic-eruption.html

Volcano eruption Pictures

Posted by: lornecjones | October 21, 2009

Compare Time

string start = System.Configuration.ConfigurationManager.AppSettings["start"].ToString();
string end = System.Configuration.ConfigurationManager.AppSettings["end"].ToString();

if (System.DateTime.Now.Hour >= Convert.ToInt32(start) && System.DateTime.Now.Hour <= Convert.ToInt32(end))
{
Response.Write("OK");
}

Posted by: lornecjones | October 19, 2009

Quick Calculating Percentages

I always need to calculate percentages, so I wanted to once and for all put an entry that is easy to use and remember:
To do a quick calculation, subtract the discount percentage from 100, and
use that number as a percentage multiplier to get the discounted price. For
example:
say there is an item for $45.00, with a 15% discount.
100 minus 15 is 85.
Your new price would be 85% of the old price, so you can multiply the old
price by 0.85, which is 85 percent written in decimal form.
0.85 times $45.00 is $38.25; this is the discounted price.

Reference:

http://www.newton.dep.anl.gov/askasci/math99/math99056.htm

Posted by: lornecjones | April 22, 2009

Slow Mo is Cool

Take a look at this…wow!


Click here!!!







from David Coiffier on Vimeo.

Posted by: lornecjones | April 20, 2009

Thanks Erwin…How to create Master Page in GAC

Creating the Master Page
1. create a new website
2. delete any default pages that are not needed like the default.aspx
3. add a master page to the website and called it “MasterPageBase.master”
Note: Only use Server Controls!

Note: Do not use any HTML controls, this will break the dll

Header

MasterPageBase.master

Note: Add any single occurance tags in the MasterPageBase.Master. Ex: Form, ScriptManager tags
Creating the dll
1. create a key file with the Strong Name tool (sn.exe)
sn -k masterpage.snk
2. publish the website with the following options:
• Use fixed naming and single page assemblies
• Enable strong naming on precompiled assemblies
• Mark assemblies with AllowPartiallyTrustedCallerAttribute (APTCA)

3. This should generate a file in the published folder called App_Web_masterpagebase.master.cdcab7d2.dll. Copy this dll into the assembly folder which is usually located at “\windows\assembly”
Implementing the Master Page on a Web Application
1. Create a new web application
2. Add the Master Page assembly in the web.config
Note: Make sure that you change the PublicKeyToken if you copy the code below.

3. Add a new Master Page and called it “Site1.Master”
4. Delete any code behind(.cs) that comes with Site1.Master
5. Edit the Site1.Master

6. Create a Web Page and use the Site1.Master

The body goes here

Note: If you are implementing the (GAC) Master Page into existing web applications, make sure to remove the form tags and scriptmanager tags.
Resource Files in the (GAC) Master Page
1. Create a new web site
2. Delete the file that are not needed such as default.aspx and web.config
3. Add a new ASP.net folder “App_GlobalResources”
4. Add a resource file in the App_GlobalResources and called it LocalizedText.resx
5. Enter the Name/Value pairs in the LocalizedText.resx
6. create a key file with the Strong Name tool (sn.exe)
sn -k masterresource.snk
7. publish the website with the following options:
• Use fixed naming and single page assemblies
• Enable strong naming on precompiled assemblies
• Mark assemblies with AllowPartiallyTrustedCallerAttribute (APTCA)

8. This should generate a file in the published folder called App_GlobalResources.dll. Copy this dll into the assembly folder which is usually located at “\windows\assembly”
9. Add a reference of the App_GlobalResources in Master Page’s web.config

Note: Change the PublicKeyToken if you copy the code below

10. Load the resource file in the MasterPageBase.master.cs
lblHeader.Text = Resources.LocalizedText.lblHeader;
Auto Complete in the (GAC) Master Page
1. Create a new Web Application and create a web service
2. Implement the web service in MasterPageBase.Master by specifying the full url ex: “http://yourwebsite//search.asmx”

Common Problems
• OnClick event not executing: add the CausesValidation=”false”

• Master Page is not updating: make sure to stop the IIS every time the Master Page dll changes
• Referencing the controls in JavaScript: make sure to add the contentPlaceHolder as a prefix of the control id. View the rendered HTML source code to verify the rendered control id.
document.getElementById(“ctl00_ContentPlaceHolder1_txtSearch”);
• Some HTML tags doesn’t work: Do not use HTML tags! Only use Server Controls.

Posted by: lornecjones | April 20, 2009

Email is always needed also – C#

MailMessage message = new MailMessage();
message.From = new MailAddress(“sender@foo.bar.com”);

message.To.Add(new MailAddress(“recipient1@foo.bar.com”));
message.To.Add(new MailAddress(“recipient2@foo.bar.com”));
message.To.Add(new MailAddress(“recipient3@foo.bar.com”));

message.CC.Add(new MailAddress(“carboncopy@foo.bar.com”));
message.Subject = “This is my subject”;
message.Body = “This is the content”;

SmtpClient client = new SmtpClient();
client.Send(message);

Posted by: lornecjones | April 20, 2009

Steps to Localizing your Web Site With Resources

Steps for Converting an Application to be Translated using Resources Files and Master Page

1. Generate Local Resources
a. Note: Some local resources may not generate if converted to a newer visual studio and / or within a panel. Must check each one on the page in HTML Source View in Visual Studio.
b. Add any non generated resource file strings to Local Resources.
2. Update the cs file to include the following code:

string CurrentURL = Request.ServerVariables["HTTP_Host"].ToString();
//string CurrentURL = “www.mmm.de”;
//Intialize Country code
string countrycode = “”;

//Intialize CountryTrans .dll
CountryTrans.Country trans = new CountryTrans.Country();

//get country from CountryTrans .dll
countrycode = trans.GetCountrybySite(CurrentURL);
Session["countrycode"] = countrycode;
// //Set the CultureInfo to generic countrycode, which will be used throughout application to switch text to correct language
Thread.CurrentThread.CurrentUICulture = new CultureInfo(countrycode);
Thread.CurrentThread.CurrentCulture = new CultureInfo(countrycode);

3. Add the following .dll “CountryTrans.dll”
4. Make a global resource folder by right-clicking project and add “ASP.NET Folder” Global Resource folder
5. Add Global resource file to the Global Resource folder (such as “grs.resx”)
6. This file will serve all cs file text strings that will display to user. Such as error text, labels that are initialized within the cs file, etc.
7. To replace text you can use the following:
a. String OnpageError.Text = (String)GetLocalResourceObject(“OnpageErrorResource1.Text”).ToString(); -use for LocalResources

Or for Global strings

b. (String)GetGlobalResourceObject(“”,” ”).ToString();
i. Tip – Global resources can be reused…
8. Once complete, copy the local resource file and make a copy with the culture desired as an internal extension within the file name of the new resource file. For example, if German is desired, then copy the original “Default.aspx.resx” and change pasted file to “Default.aspx.de.resx”…repeat for each culture desired for translation.
9. Do the same for the global resource file as well. (For example, “gsr.de.resx” for German)
10. Then once done, change the domain on page load to test that German (or some other language(culture) will replace the text). It is important to note that, the German strings in the resource files must also, be changed to the German text to have an accurate test. Run the page with that url and the text should be replaced).

To add a master page that was added to a GAC, do the following:

1. Add the web config values (assembly, and connection string for the master page if necessary)
2. Create a child master and add the Master page CSS to the child page. Then move any css links and/or javascript links to the child page(s). For example:

3. Add the masterpage .ddl to the project as a reference
4. Add the following sections (in yellow) to the web config:

.
.
.

5. Remove all other cs pages or other pages from the child.master
6. Then on the target page, remove the Head tags, and html, body, form tags.
7. Add MasterPageFile=”~/Child.Master” to the html source page
8. Enclose the head section with
9. And enclose the body section in:
10.
11. Done!

Posted by: lornecjones | April 20, 2009

Localization and Globalization Code C#

using
System.Globalization;
using
System.Threading;

(
String)GetGlobalResourceObject(“globalresource”, “ordernumber”).ToString();

(
String)GetLocalResourceObject(“tbxCRLAcctNumResource1.Title”).ToString();

 

string CurrentURL = Request.ServerVariables["HTTP_Host"].ToString();
//string CurrentURL = “www.mmm.de“;
//Intialize Country code
string countrycode = “”;
//Intialize CountryTrans .dll
CountryTrans.
Country trans = new CountryTrans.Country();
//get country from CountryTrans .dll
countrycode = trans.GetCountrybySite(CurrentURL);
Session[
"countrycode"] = countrycode;
// //Set the CultureInfo to generic countrycode, which will be used throughout application to switch text to correct language
Thread.CurrentThread.CurrentUICulture = new CultureInfo(countrycode);
Thread.CurrentThread.CurrentCulture = new CultureInfo(countrycode);

Posted by: lornecjones | April 20, 2009

C# Months Code -

You can always use a yearly else if then:
int monthnum = DateTime.Now.Month;
string month = “”;
if (monthnum == 1)
{
month=”jan”;
}
else if (monthnum == 2)
{
month=”feb”;
}
else if (monthnum == 3)
{
month=”mar”;
}else if (monthnum == 4)
{
month=”apr”;
}else if (monthnum == 5)
{
month=”may”;
}else if (monthnum == 6)
{
month=”jun”;
}else if (monthnum == 7)
{
month=”jul”;
}else if (monthnum == 8)
{
month=”aug”;
}else if (monthnum == 9)
{
month=”sep”;
}else if (monthnum == 10)
{
month=”aug”;
}else if (monthnum == 11)
{
month=”nov”;
}else
{
month=”dec”;
}

Posted by: lornecjones | April 20, 2009

Join Example

select * from (
>> select br from m1b
>> ) as t1 left join (
>> select branch, invoice, credit_memos, bookings from (
>> select M3BH_LVL, max(m3bh_dte) as m3bh_dte from m3btblhistory group by
>> M3BH_LVL
>> ) as t1 left join (
>> select Branch=M3BH_LVL,Invoice =
>> (m3bh_marinv),Credit_Memos=(m3bh_marcm),Bookings=((m3bh_mpoent)+(m3bh_mpoadj)),
>> m3bh_dte from m3btblhistory
>> ) as t2 on t1.M3BH_LVL = t2.Branch and t1.m3bh_dte = t2.m3bh_dte
>> ) as t2 on t1.br = t2.branch left join (
>> Select Branch=C2Gh_BR, [Last Year]=Sum([NetSalesLastYear feb]),
>> [This Year]= sum([NetSalesThisYear feb]),
>> Goals=Sum([feb goal])
>> from vwGoalActualHistory
>> group by C2Gh_BR
>> ) as t3 on t1.br = t3.branch

Older Posts »

Categories

Follow

Get every new post delivered to your Inbox.