December 2008 - Posts

One of the most time consuming things to do when starting a new web project is setting up the sites directory structure, until recently. I finally took the time to create myself a few generic templates for Visual Studio enviroment.  This has made my ramp up time on starting a new project close to nil. I have my folder stucture all set.  I created a few Classes that I typically create in all my projects, add a small library of default images and now just recently dialed the application in with jQuery wired up. Check out Sara Ford's article on making project templates in VS 2005 (Works the same in VS 2008). http://blogs.msdn.com/saraford/archive/2008/10/16/did-you-know-you-can-create-project-templates-336.aspx

 

One of the files in my project template is a class file I call SiteConfigs. This file contains all my values in my webconfig files appsettings and connectionstrings. Putting them in this file saves me the time of typing in ConfigurationManager.AppSettings("WebDomain").ToString() everytime I want to access my webconfig. It also provides me with intellisense for all my keys in my appsettings/connectionstrings. Now all I do is...

 

Response.Write("Code Version: " & SiteConfigs.CodeVersion)

 

Here's an example.

 

<WEB.CONFIG> 

 

<appSettings>

    <add key="WebUrl" value="127.0.0.1"/>

    <add key="WebDomain" value="127.0.0.1"/>

    <add key="ApplicationName" value="/"/>

    <add key="CodeVersion" value="1.0.0"/>

</appSettings>

<connectionStrings>

    <add name="SiteCS" connectionString="Data Source=;Initial Catalog=;Persist Security Info=True;User ID=;Password=" providerName="System.Data.SqlClient"/>

    <add name="ADConnectionString" connectionString=""/>

</connectionStrings>

 

<SITECONFIG.VB> 

 

Public Class SiteConfigs

 

#Region "APPSETTINGS"

 

    Public Shared ReadOnly Property WebUrl() As String

        Get

            Return ConfigurationManager.AppSettings("WebUrl").ToString()

        End Get

    End Property

 

    Public Shared ReadOnly Property WebDomain() As String

        Get

            Return ConfigurationManager.AppSettings("WebDomain").ToString()

        End Get

    End Property

 

    Public Shared ReadOnly Property ApplicationName() As String

        Get

            Return ConfigurationManager.AppSettings("ApplicationName").ToString()

        End Get

    End Property

 

    Public Shared ReadOnly Property CodeVersion() As String

        Get

            Return ConfigurationManager.AppSettings("CodeVersion").ToString()

        End Get

    End Property

#End Region

 

#Region "CONNECTIONSTRINGS"

 

    Public Shared ReadOnly Property SiteCS() As String

        Get

            Return ConfigurationManager.ConnectionStrings("SiteCS").ToString()

        End Get

    End Property

 

    Public Shared ReadOnly Property ADConnectionString() As String

        Get

            Return ConfigurationManager.ConnectionStrings("ADConnectionString").ToString()

        End Get

    End Property

 

#End Region

 

End Class

This is something I threw together when having to relink a couple dozen InfoPath libraries all containing 100-1000 forms. Why Microsoft doesn't have a check all button at the top of the page is beyond me. Here it is...

1) Open the library. Click Settings -> Form Library Settings -> Relink documents to this Library
2) Open this page in SharePoint designer.
2) Add this to the top of the page after the <Form> tag.

<script type="text/javascript" language="javascript">
function CheckAll(chk)
{
for (i = 0; i < chk.length; i++)
chk[i].checked = true ;
}
</script>
<input type="button" value="Check All" onclick="CheckAll(document.aspnetForm.chkRepair)" >

3) Save, Refresh the page, click and thank me :)!

Maybe someone from the ASP.Net community can enlighten me, I have always had the hardest time getting the script, css, etc working/rendering correctly when used on the masterpage. On the masterpage I always have to use an absolute path on the script or link tag or generate the script/link tag from the code behind on the masterpage in order for it to render/execute properly. Is there a better method. I recently ran accross this using jQuery trying to get the intellisense to work on the pages inheriting the master page.This is what I came up with. Seems like a hack. Any suggestions?

MasterPage head tag:

Head

I read Scott G's post on jQuery and intellisense and it works great for non-masterpaged files.  Does anyone else have methods that don't seem so hacked.

More Posts