Sunday, February 28, 2010

Error: Code blocks are not supported in this context

Error: Code blocks are not supported in this context
Stack Trace: at System.Web.UI.ControlBuilder.AppendSubBuilder(ControlBuilder subBuilder) at System.Web.UI.TemplateParser.AppendSubBuilder(ControlBuilder builder, ControlBuilder subBuilder) at System.Web.UI.TemplateParser.ProcessCodeBlock(Match match, CodeBlockType blockType, String text) at System.Web.UI.TemplateParser.ParseStringInternal(String text, Encoding fileEncoding) at System.Web.UI.TemplateParser.ParseString(String text, VirtualPath virtualPath, Encoding fileEncoding)
Cause of Error:
This error occurs mainly if your .aspx page, html tags are not closed properly or you have Bad Html tags which could lead to Html Parser error.
Example: I was playing with FreeTextBox, in Html mode. Suddenly a Phone rangup and forget to close Html tag inside FreeTextbox.


<FTB:FreeTextBox ID="FreeTextBox1" runat="Server"
Width="700" Height="500" TabIndex="8" DisableIEBackButton="true">
<Toolbars>
<FTB:Toolbar>
<FTB:InsertHtmlMenu runat="server" Title="Insert Code">
<Items>
<FTB:ToolbarListItem Text="Student" Value="<img
src='<%= Page.ResolveUrl("
~")%&gt;Images/add_buddy.gif' />"
runat="server" />
</Items>
</FTB:InsertHtmlMenu>
</FTB:Toolbar>
</Toolbars>
</FTB:FreeTextBox>

Solution:
Remove Bad Html or rectify Bad Html part from your .aspx page and this error would get resolved.

Saturday, February 27, 2010

Google Buzz Posting from Asp.net Web Application

Earlier I have discuss about how to post tweet from asp.net web application. In this article I would discuss how to post google buzz from asp.net web application.

What is Google Buzz
Google Buzz is Twitter like service from google, inside gmail.

Following Procedure explains how to send google buzz from asp.net website without using google buzz api.

Step 1: As Google Buzz require a valid gmail account. You need to decide, from which gmail account you would like to post google buzz. For this example, i would be posting google buzz from my gmail account. i.e. dotnetguts [at the rate] gmail [dot] com.

Step 2: Enable Google Buzz posting by sending email. Please follow following to do so.
a) Log into your gmail account.

b) Open Google Buzz.

c) Click on Connected Sites link as shown in figure.


d) Click on Add button associated with "Post via buzz@gmail"


e) Click on save button.


Step 3: Open Visual Studio and create new asp.net website.

Step 4: Arrange web control as shown in following figure.



Step 5: Call following Function from Button Click Event.


private void PostBuzzMsg(string strEmail, string strPassword, string BuzzMsg)
{
//Create Mail Message Object with content that you want to send with mail.
System.Net.Mail.MailMessage MyMailMessage =
new System.Net.Mail.MailMessage(strEmail, "buzz@gmail.com",
BuzzMsg + "... http://dotnetguts.blogspot.com", string.Empty);

MyMailMessage.IsBodyHtml = false;

//Proper Authentication Details need to be passed when sending email from gmail
System.Net.NetworkCredential mailAuthentication = new
System.Net.NetworkCredential(strEmail, strPassword);

//Smtp Mail server of Gmail is "smpt.gmail.com" and it uses port no. 587
//For different server like yahoo this details changes and you can
//get it from respective server.
System.Net.Mail.SmtpClient mailClient =
new System.Net.Mail.SmtpClient("smtp.gmail.com", 587);

//Enable SSL
mailClient.EnableSsl = true;

mailClient.UseDefaultCredentials = false;

mailClient.Credentials = mailAuthentication;

mailClient.Send(MyMailMessage);
}

Step 6: Run asp.net website and Send Message.



Now Check your Buzz to see how message appears.

Most Recent Post

Subscribe Blog via Email

Enter your email address:



Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.
Page copy protected against web site content infringement by Copyscape