I am using the Training Fab 40 template to build a training site in MOSS 2007. I have another content type for my Course list. I want to load the NewForm.aspx based on Content Type selected. The two content types are "Classroom Training" and "Offline Training". Although the NewForm should automatically get modified based on content type, but since I have modified the NewForm.aspx, it is not loading. I even tried to change the forms from SharePoint Designer via List properties, but in-vain.

Is there a way I can redirect to separate forms via JavaScript or anything else?


I have done this in 2010 using C# but not JavaScript. I assume the concept should be the same though.

To load the NewForm based on Content Type, you have to pass the content type GUID to the NewForm.aspx page.

I have a custom dropdown that lets a user select a content type from the list. I do this with the following C# code:

using (SPWeb web = SPContext.Current.Web)
    SPList contracts = web.Lists["Contracts"];
    SPContentTypeCollection ctColl = contracts.ContentTypes;
    StringBuilder sb = new StringBuilder();
    sb.Append("<div id='dropdown'><button id='dropdownButton'>Submit a new contract approval request</button></div><ul>");

    foreach (SPContentType ct in ctColl)
        if(ct.Name != "Folder")
            string ctLink = string.Format("{0}?ContentTypeID={1}", contracts.DefaultNewFormUrl, ct.Id.ToString());

            // link to the preform with destination link as query string parameter
            string preFormLink = web.Url + "/_layouts/ContractApproval/NewContractPreForm.aspx?dest=" + Server.UrlEncode(ctLink);

            //string link = string.Format("<a href='javascript:OpenModal(\"{0}\", \"Contracts - New Item\")'>{1}</a>", ctLink, ct.Name);

            string link = string.Format("<a href='{0}'>{1}</a>", preFormLink, ct.Name);

            sb.AppendFormat("<li>{0}</li>", link);

    LiteralControl lc = new LiteralControl(sb.ToString());

Your URL should look something like this:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.