Tuesday, 17 November 2009

Generic method to get control from LoginView

private T GetLoginViewControl(string name) where T : Control
{
return LoginView1.FindControl(name) as T;
}

Sunday, 8 November 2009

Dual monitors not working for new install of Windows 7 on Dell M2300 laptop

I recently did a brand new install of Windows 7 Professional on my Dell Precision M2300 laptop. When I connected my monitor or TV to the laptop it was not picked up by 7.

The solution was to go onto Dell.co.uk and download the Nvidia Quadro FX 360 for Vista 32bit not Windows 7 as it is not supported.

Thursday, 5 November 2009

Browser CSS Overrides

The following is a quick reference on how to override CSS styles in different browsers.

#body
{
margin:10px; /* All browsers */
}
#body
{
margin:10px;
*margin:5px; /* IE6 Override */
}
#body, x:moz-any-link
{
margin:4px; /* Only Firefox */
}

This link is very useful: CSS Hacks

Monday, 28 September 2009

SoapException: UnauthorizedAccessException

I started getting this error when I replace my existing COM object with an updated version. In order to get it to work I gave full permissions to the dll for ASPNET user.

"System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {69F9C9A0-2E91-4E87-B089-02393AB1E665} failed due to the following error: 80070005.\n at ChoicesSurveyWS.SurveyWS.GetSurveyList(String strUser, String strPass) in C:\\DevProjects\\web\\NETQuest\\WebServices\\ChoicesSurveyWS\\SurveyWS.asmx.cs:line 56\n --- End of inner exception stack trace ---"

Monday, 17 August 2009

Rounded corners no images and no JavaScript

Rounded corners style with no images and no javascript:http://blog.benogle.com/2009/04/29/css-round-corners/

Monday, 13 July 2009

Merge simillar XML documents with LINQ

Say you had this XML:


... and this XML:



Now you want to merge the 2 based on "name" and you want to include additional elements that could be in either sequence. This code should do it:

var master = XDocument.Parse(masterXml);
var current = XDocument.Parse(currentXml);

// Concatenate the two XML decendent nodes together so we have all the nodes.
var all = master.Descendants("Audience").Concat(current.Descendants("Audience"));

// Group them by name to get unique names.
var unique = from a in all
group a by a.Attribute("name").Value into groups
select groups;
// When merging...
// "name" is the key in the group above
// "expr" can have multiple values so seperate with pipe character |
// "factor" both values will alway be the same so select the first
var merged = from u in unique
select new XElement("Audience",
new XAttribute("name", u.Key),
new XAttribute("expr", string.Join("|", u.Select(x => x.Attribute("expr").Value).ToArray())),
new XAttribute("factor", u.Select(x => x.Attribute("factor").Value).First())
);


Friday, 19 June 2009

Add web reference as a service reference

With the introduction of WCF I am attempting to add my existing web service (ASMX) to a class library but using WCF service references.

So I have this web service URL i.e. http://localhost/ChoicesSurveyWS/SurveyWS.asmx
  • I create a new class library project.
  • I right-click on the new class library and select "Add service reference".
  • A dialog pops up and I place my web service URL into the "Address" bar.
  • Click "Go".
  • Type in a new namespace name i.e. SurveyService.
  • Click "Ok".


Now a service reference is added to the project and an app.config file.
  • Create a new console project to be the client (consumer) of the web service.
  • Add the class library we created as a project reference to the console project.

*NB* MOVE THE app.config FILE FROM the class library into the console project. This will prevent you getting an error like this:

Could not find default endpoint element that references contract in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element match