Showing posts with label microsoft. Show all posts
Showing posts with label microsoft. Show all posts
Monday, January 12, 2009
Globalization and Localization in ASP.Net 2.0
I would really love to write about this topic that my drool flooded my laptop and broke it. I just implemented this on my new project and its working perfectly compared to the one our company is currently using. So without further ado, i would like to present...............the link, everything you need to know is already in there.
Labels:
asp.net,
globalization,
microsoft,
resource,
visual studio 2005
Saturday, January 3, 2009
Simple Delegate and Event Implementation Sample
class definition:
public class DelegateAndEvent
{
//it is a good practice to name your delegates with "EventHandler"
public delegate void ErrorEventHandler(DelegateAndEvent sender, ErrorEventArgs args);
//declare event
public event ErrorEventHandler ErrorRaised;
//a better way of returning values is to create a class which inherits the EventArgs class and add the
//desired property(ies)
public class ErrorEventArgs : EventArgs
{
private string _errmsg;
public string ErrorMessage
{
get { return _errmsg; }
set { _errmsg = value; }
}
public ErrorEventArgs() { }
public ErrorEventArgs(string error)
{
_errmsg = error;
}
}
/// Method to allow raising of error (can either be public or private)
public void RaiseError(string error)
{
if (!string.IsNullOrEmpty(error))
{
//check is event is not null (event has a subscriber)
if (ErrorRaised != null)
{
ErrorRaised(this, new ErrorEventArgs(error));
}
}
}
}
code behind:
public partial class _Default : System.Web.UI.Page
{
DelegateAndEvent dne = new DelegateAndEvent();
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
dne.ErrorRaised += new DelegateAndEvent.ErrorEventHandler(dne_ErrorRaised);
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnEvent_Click(object sender, EventArgs e)
{
dne.RaiseError("Error was forced to be raised!");
}
void dne_ErrorRaised(DelegateAndEvent sender, DelegateAndEvent.ErrorEventArgs args)
{
lblError.Text = args.ErrorMessage;
}
}
Simple Delegate and Event Implementation Sample
Monday, December 29, 2008
Dynamic Web Reference for ASP.Net Class Projects
Usually web service references are added on the main web application but what if you want to isolate it since you'll only be using it on your business layer (class project); the answer, of course, is to add it on your class project. Great, but what if the web service is suddenly relocated to another server? Wouldn't it be nice if you'll have a way to just change the url and point it to the new web service url? To accomplish that, simply follow the following instructions:
1. Set your Class Project Web Reference' URL Behavior property to 'Dynamic'.
2. Open the app.config. The first step will generate an appsettings entry for your web service. Copy the generated appsettings entry.
3. Go to your web application web.config and paste it inside the appSettings and your done.

1. Set your Class Project Web Reference' URL Behavior property to 'Dynamic'.
2. Open the app.config. The first step will generate an appsettings entry for your web service. Copy the generated appsettings entry.
3. Go to your web application web.config and paste it inside the appSettings and your done.
Dynamic Web Reference for ASP.Net Class Projects
Sunday, December 28, 2008
How to access web.config from a class project assembly
With VS 2005 it is now easy to access your web.config file from a class within any of your class projects. This is useful for cases wherein your Data Layer needs to access your web.config to retrieve the connectionString section.

public static string GetConnectionStringFromWebConfig()
{
System.Configuration.Configuration cfg =
return cfg.ConnectionStrings.ConnectionStrings[0].ConnectionString;
}
{
System.Configuration.Configuration cfg =
System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~");
//wfp - open web.config located in the root directoryreturn cfg.ConnectionStrings.ConnectionStrings[0].ConnectionString;
}
of course plain old ConfigurationManager can still be used.
How to access web.config from a class project assembly
Labels:
.net,
access from assembly,
connectionstring,
microsoft,
web.config
the links
first offering.

this entry will be updated everytime i found new links which i've found useful. the link name pretty much describes what you'll expect so don't whine about 'a short description would be nice' okay (trying to make an excuse for being lazy to provide one)
the links
Labels:
.net,
ajax,
c#,
css,
javascript,
microsoft,
sql server,
visual studio,
xhtml
Subscribe to:
Posts (Atom)