Blog Archives

JQuery Is Not Defined

This is a common error for users implementing JQuery UI. Usually if you see this message, this could mean a few things:

– There is a syntax issue or bad link referencing the JQuery (min/full) JS. Use your debuggers to make sure the JS is loading.

– Similar to above this could also mean the JS cannot be loaded due to being contained in a folder which the site does not have permission to.

– If you are debugging locally and referencing the JQuery JS on an external site, make sure you have internet access and that the site which you are referencing to is up.

– The arrangement of script references may be in the wrong order. JS loads on runtime, so dependencies are important in placement of the script reference on the page. JQuery UI depends on JQuery(min), so (min) must be declared first or you will encounter the error.

As always, Firebug and other web development debuggers such as the one’s built into Chrome and IE are great tools to help you identify and resolve issues such as these.

Hope this may lighten someone’s day. 🙂

    <script src="../JQuery/js/jquery-1.4.4.min.js" type="text/javascript"></script>

    <link href="../JQuery/css/smoothness/jquery-ui-1.8.7.custom.css" rel="stylesheet"
        type="text/css" />

    <script src="../JQuery/js/jquery-ui-1.8.7.custom.min.js" type="text/javascript"></script>

JQuery UI,


Get Current Page Name in ASP .NET

The code snippet below is a quick, easy to use function which allows you to get the current active page in an asp .net website/application.

There are similar functions for getting header information about a page, however, after some research I found the direct info I was looking for was much easier to retrieve using this method.

Enoy. 😉


Public Function GetCurrentPageName() As String
	Dim strPath As String = System.Web.HttpContext.Current.Request.Url.AbsolutePath
	Dim oInfo As New System.IO.FileInfo(strPath)
	Dim strPageName As String = oInfo.strPageName 
	Return strPageName
End Function


public string GetCurrentPageName() 
    string spath = System.Web.HttpContext.Current.Request.Url.AbsolutePath; 
    System.IO.FileInfo oInfo = new System.IO.FileInfo(spath); 
    string spagename = oInfo.Name;
    return spagename;

Programmatically fire an event handler in ASP .NET

I recently came across a situation which any web application developer may face where an assembly reference containing the code-behind for each ASPX page was deprecated and the original source code was no longer available.

Since this code also includes event handlers, any functions that need to be intercepted or their logic modified are now inaccessible.

In many cases these event-handling functions are also declared protected, so simply calling them from the ASPX side is not possible.

To circumvent this, one of my personal favorite .NET libraries can be used to get the method using reflections and call it manually. See examples in VB and C# below.

Enjoy. 😉


    Private Sub btnLogin2_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnLogin2.Click
        Dim targetObject As Object = btnLogin
        Dim methodName As String = "OnClick"
        Dim mInfo As System.Reflection.MethodInfo = targetObject.GetType().GetMethod(methodName, System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.NonPublic)
        If mInfo Is Nothing Then
            Throw New ArgumentException("Error finding event handler:  " & methodName)
        End If
        mInfo.Invoke(targetObject, New Object() {e})
    End Sub


private void btnLogin2_Click(object sender, System.Web.UI.ImageClickEventArgs e)


	object targetObject = btnLogin;

	string methodName = "OnClick";

	System.Reflection.MethodInfo mInfo = targetObject.GetType().GetMethod(methodName, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);

	if (mInfo == null) {
		throw new ArgumentException("Error finding event handler:  " + methodName);

	mInfo.Invoke(targetObject, new object[] { e });

It is generally not good security practice IMO to write code in the ASPX side of a web application. This solution will work however as a quick patch to an application in which the code-behind is not accessible and the site is not accessible by outside parties via (S)FTP.

If security is of concern, another solution which is the better option overall, would be to declare a new class for which this page would inherit from. In this class you could then define a public property which exposes the protected function to be called by other methods, and/or simply write your new functions and logic in here.

If the page is a partial class (as most ASP.NET web applications are structured), this is also possible without inheritance by declaring a new partial class which shares the same type as your page you need to modify. New logic can be added here and/or protected members can be exposed via public properties.

If either inheritance/OO approach is taken, upon deployment or build of the project, your new class will be compiled into a new assembly and now achieve desired functionality while maintaining security of the application as well.