Archive for category Web Development
Where/How do we place/refer to images in SharePoint 2010 WebParts
Posted by Imran Akram in SharePoint 2010, Web Development on April 17, 2011
This one is especially useful for the new bie because when you start with building webparts for SharePoint 2010, you often come to a point where you wanna add a URL somewhere, lets say programatically or in the CSS or may be in the ASCX code and you wonder, hey wait a minute where are the images for SharePoint placed anyway? How do I refer to them? So here’s your answer.
What you do is that you Right Click the Web parts project > Add > SharePoint “Images” Mapped Folder option. Doing that will give you an images folder inside your project directory and you can refer to that like this:
“~/_layouts/Images/ProjectNamesETC/xyz.png”
Have fun!
How to change the Internet Zone security level from High to Medium-Low in Windows Server 2008
Posted by Imran Akram in Web Development on January 25, 2011

Figure 1 - Where is the Enhanced Security Configuration for Internet Explorer in Windows Server 2008 - Server Manager
Ever tried testing your application on Internet Explorer in a Windows Server environment and noticed that you just can’t browse like you do normally. In short, its “a pain in the ass”! (pardon my French) because IE just keeps buging you at every single URL that you enter – and not just once… but 3-4 times for a single website. And in order to see the looks of that website, you have to keep adding in the “trusted zone” in the dialog box that appears all the time! But anyway, enough of this whining now, lets get down to some business.
Well, today I was really determined to stop all those nonsensical security alerts so first I went to where common sense leads you to – Yeah you’re right, I went to the Internet Options –> Security Tab –> Internet Zone to turn down the security level. But when you go there, it appears disabled (grayed-out), so obviously you can’t change that like the way you’d usually expect! (Wonder why Microsoft did it that way?!?! But anyway…)
So going to the good ol’ Google for help and reading a document on Microsoft, I cam to know that all you need to do, is to fire up Server Manager (usually it sits in the Quick Launch bar but you can also go to Control Panel –> hit Classic view –> Programs and Features –> Turn Windows features on or off). Once you’re there, you’d see the screen similar to Figure 1 above. In that just hit the link Configure IE ESC. Next up, you’d see the screen in figure 2 on the right. Just turn the IE Enhanced Security Configuration (IE ESC) off for the administrators. It is recommended however, that you do turn it back on when you put the server into production. After you’re done with that you can go back to Internet Explorer –> Internet Options –> Security tab –>Internet zone and bring it down to medium-low. Now you can browse as usual.
I hope you find this post useful although it seems like a very trivial issue yet its quite annoying when you’re in a hurry or something.
So keep the feedback coming in, I’d be more than
happy to hear from ya!
Unknown server tag ‘asp:ScriptManager’ After having AjaxControlToolkit.dll referenced
Posted by Imran Akram in ASP .NET, Web Development on July 24, 2009
Yesterday I was working on a project which had the AJAX Extensions in use. It’s primarily a .NET 2.0 application and I had .NET Framework 3.5 SP 1 installed on my system. It was working normally and all of a sudden I got this error that: Unknown server tag ‘asp:ScriptManager’
It was strange because every thing was working and I had the reference to the AjaxControlToolkit.dll.
I found out that by adding the section below to the <system.web> node in the web.config solves the problem:-
<pages>
<controls>
<add tagPrefix=”asp” namespace=”System.Web.UI” assembly=”System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ />
</controls>
</pages>
Useful Regular Expression for a UserName
Posted by Imran Akram in ASP .NET, Web Development on May 17, 2009
^[a-zA-Z0-9_\.\-]+$
Allows only Alphanumeric characters with a period(.), Underscore(_) and a Hyphen (-). No spaces or other characters allowed.
Regular Expression Testing Tool, The Regulator
Posted by Imran Akram in ASP .NET, Web Development on May 15, 2009
I’ve found this tool called The Regulator, for validating and testing the regular expressions very useful. I think some of you might find it fairly useful as well. The interface is pretty neat, very simple to use. In case you find it a bit confusing, press F1 to checkout the basics. It’s pretty much straight forward.
How to detect a mobile browser in ASP.NET
Posted by Imran Akram in ASP .NET, Web Development on March 31, 2009
I’ve been having this issue with mobile development for quite sometime that I couldn’t get the mobile browser accurately by just using the Request.Browser.isMobileDevice property and I’ve found this piece of code here
Looks pretty useful.
public static bool isMobileBrowser()
{
//GETS THE CURRENT USER CONTEXT
HttpContext context = HttpContext.Current;
//FIRST TRY BUILT IN ASP.NT CHECK
if (context.Request.Browser.IsMobileDevice)
{
return true;
}
//THEN TRY CHECKING FOR THE HTTP_X_WAP_PROFILE HEADER
if (context.Request.ServerVariables["HTTP_X_WAP_PROFILE"] != null)
{
return true;
}
//THEN TRY CHECKING THAT HTTP_ACCEPT EXISTS AND CONTAINS WAP
if (context.Request.ServerVariables["HTTP_ACCEPT"] != null &&
context.Request.ServerVariables["HTTP_ACCEPT"].ToLower().Contains(“wap”))
{
return true;
}
//AND FINALLY CHECK THE HTTP_USER_AGENT
//HEADER VARIABLE FOR ANY ONE OF THE FOLLOWING
if (context.Request.ServerVariables["HTTP_USER_AGENT"] != null)
{
//Create a list of all mobile types
string[] mobiles =
new[]
{
“midp”, “j2me”, “avant”, “docomo”,
“novarra”, “palmos”, “palmsource”,
“240×320″, “opwv”, “chtml”,
“pda”, “windows ce”, “mmp/”,
“blackberry”, “mib/”, “symbian”,
“wireless”, “nokia”, “hand”, “mobi”,
“phone”, “cdm”, “up.b”, “audio”,
“SIE-”, “SEC-”, “samsung”, “HTC”,
“mot-”, “mitsu”, “sagem”, “sony”
, “alcatel”, “lg”, “eric”, “vx”,
“NEC”, “philips”, “mmm”, “xx”,
“panasonic”, “sharp”, “wap”, “sch”,
“rover”, “pocket”, “benq”, “java”,
“pt”, “pg”, “vox”, “amoi”,
“bird”, “compal”, “kg”, “voda”,
“sany”, “kdd”, “dbt”, “sendo”,
“sgh”, “gradi”, “jb”, “dddi”,
“moto”, “iphone”
};
//Loop through each item in the list created above
//and check if the header contains that text
foreach (string s in mobiles)
{
if (context.Request.ServerVariables["HTTP_USER_AGENT"].
ToLower().Contains(s.ToLower()))
{
return true;
}
}
}
return false;
}
How to use an OR in a query in EntitySpaces?
Posted by Imran Akram in ASP .NET, C#, Web Development on March 25, 2009
It’s simple, yet not very obvious. All you have to do is to change the normal behavior of the commas you use in the Where function to act as an OR. You’d do it like this:-
ObjES.Query.es.DefaultConjunction = esConjunction.Or;
ObjES.Query.Where(<<Go ahead with using the commas that usually defaults to an AND conjunction>>);
oh and I almost forgot to mention my colleague Bilal mentioned this to me. So special thanks to him as well.

