Category Archive » C#

Sys.WebForms.PageRequestManagerParserErrorException

I had the problem of page not able to redirect when in an ajax postback. It happens to be the fact that I disabled a line in web.config:

<add name=”ScriptModule” type=”System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ />.

This line should be added in HttpModules, so that redirection will work in Ajax postback. This class manages HttpModules for Ajax functionalities in ASP.NET.

How to send email via Sharepoint

This is a useful function for sending a message via Sharepoint:

private void SendEmail(SPWeb oWeb, bool appendHtmlTag, bool htmlEncode,
            String toAddress, String subject, String message, bool elevated)
        {
            //check if external email is set
            bool isExternalEmailSet = SPUtility.IsEmailServerSet(oWeb);
            if ((elevated == true) && (isExternalEmailSet == true))
            {//run elevated
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPUtility.SendEmail(oWeb, appendHtmlTag, htmlEncode, 
toAddress, subject, message);
                });
            }
            else if ((elevated != true) && (isExternalEmailSet == true))
            {//run un-elevated
                SPUtility.SendEmail(oWeb, appendHtmlTag, htmlEncode, 
toAddress, subject, message);
            }
        }

ScriptResource.axd from Ajax getting Too Big

Today I was testing the loading time of my site, which I sometimes find it slow to access especially the first time loading. I knew there are a lot of images to be loaded especially those in portfolio sections but I also found that the biggest loading item seems to be ScriptResource.axd from Ajax. It was 330kb!

Read More