This Regex will match the following Relative URLs
REGEX
-----
^(/[a-zA-Z0-9]+)+(\.[a-zA-Z]{2,4})((\?\w*=?\w*)(\&\w+=\w+)*)?$
URLs
----
/folder1/page.ax
/folder1/page.php
/folder1/folder2/page.aspx
/folder1/page.aspx?qstring1=value1 (likewise n number of query strings)
Will not match
/folder1?/page.aspx
/folder1/page.aspx?=value1
/folder1/page.aspx?qstring1=value1?qstring2=value2
^(/[a-zA-Z0-9]+)+(\.[a-zA-Z]{2,4})((\?\w*=?\w*)(\&\w+=\w+)*)?$
Wednesday, March 4, 2009
Friday, February 27, 2009
LINQ ERROR
I was working with a LINQ sample and stumbled upon the following error.
"The non-generic type 'System.Collections.IEnumerable' cannot be used with type arguments"
XML file I was using :-

Code used :-
//The application is a ASP.net page
XDocument xDoc = XDocument.Load(HttpContext.Current.Server.MapPath("Persons.xml"));
IEnumerable queryNew = from e in xDoc.Descendants("Person")
select new Person{
FirstName = e.Element("FirstName").Value,
LastName = e.Element("LastName").Value,
Salary = Convert.ToInt32(e.Element("Salary").Value)
};
Solution :- IEnumerable is present in both System.Collections.Generic and System.Collections name spaces. The query returns a generic collection. So in this case We should use System.Collections.Generic. So when I provided a "using System.Collections.Generic;" on top of the page, it did the trick for me.
"The non-generic type 'System.Collections.IEnumerable' cannot be used with type arguments"
XML file I was using :-
Code used :-
//The application is a ASP.net page
XDocument xDoc = XDocument.Load(HttpContext.Current.Server.MapPath("Persons.xml"));
IEnumerable
select new Person{
FirstName = e.Element("FirstName").Value,
LastName = e.Element("LastName").Value,
Salary = Convert.ToInt32(e.Element("Salary").Value)
};
Solution :- IEnumerable is present in both System.Collections.Generic and System.Collections name spaces. The query returns a generic collection. So in this case We should use System.Collections.Generic. So when I provided a "using System.Collections.Generic;" on top of the page, it did the trick for me.
Wednesday, December 10, 2008
Check box list validation
The following javascript will validate that atleast one checkbox is checked in a checkboxlist . And if a checkbox named 'other' is checked , it will check that a textbox that is next to it is not empty .
How to get the domainname of an ASP.Net application
If the application URL is something like www.myDomain.com/home/homepage.aspx , to get the http://www.mydomain.com/ part from it , we can use the following
(1)HttpContext.Current.Request.Url.Scheme+"://"+ HttpContext.Current.Request.Url.DnsSafeHost
or
(2)HttpContext.Current.Request.Url.Scheme+"://"+ HttpContext.Current.Request.Url.Host
(1)HttpContext.Current.Request.Url.Scheme+"://"+ HttpContext.Current.Request.Url.DnsSafeHost
or
(2)HttpContext.Current.Request.Url.Scheme+"://"+ HttpContext.Current.Request.Url.Host
Tuesday, December 9, 2008
My first post...
As developers we come accross many issues while coding . I was thinking of writing down some of the solutions that I came accross , as blog entries so that it might help others who face the same kind of issues.
Better late than never ;) ..
Better late than never ;) ..
Subscribe to:
Posts (Atom)