Sunday, May 18, 2014

Partial Page Print in HTML

To print a Partial Part of HTML page……..
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<script>
function printDiv()
{
  var printer = window.open('','','width=640,height=700');
 printer.document.open("text/html");
 printer.document.write(document.getElementById('printingstuff').innerHTML);
 printer.document.close();
 printer.window.close();
 printer.print();
 alert("Printing the \"printingstuff\" div...");
}
</script>
<title>Partial Page Printing Test Page</title>
</head>
<body>
<div id="printingstuff">
Hi Sajith, I m going to print now.....!
</div>
<div>
Hai Sajith u cant print me...!
</div>
<br /><span style="color:blue"  onclick="javascript:printDiv()">PRINT THIS PAGE</span>
</body>
</html>


Enjoy!


ref:
http://7explications.wordpress.com/2009/10/22/partial-page-print-in-html/

Saturday, May 17, 2014

Sanitizer provider is not configured in the web.config file. Ajax Control Toolkit and HtmlEditorExtender problems.

The Problem

Today I had a hard 2 hours, and if you have found this blog post, I bet we are in the same shoes.
I was working on a ASP .NET + windows azure project, and I needed the HtmlEditorExtender  control from theAjax Control Toolkit. I was lucky to find a control for my needs. So far so good.
I've installed the toolkit with NuGet Package manager, it added a reference to the assembly to my web.config. I've used the following code where I needed the HtmlEditorExtender:


<ajaxToolkit:ToolkitScriptManager runat="Server" />
<asp:TextBox
        ID="txtComments"
        TextMode="MultiLine"
        Columns="60"
        Rows="8"
        runat="server" /> 
<ajaxToolkit:HtmlEditorExtender
        TargetControlID="txtComments"
        runat="server" />
</asp:Content>

Just to see how this control works. As you can bet ajaxToolkit is the reference to the assembly.
I've hit F5 and bam this uglyness showed up:
 


Details

I've tried to search on the codeplex site of the project, but nothing was mentioned about this.
Just use it as it is. Yeah, right! I've searched on google about this problem,
and what I've found were mostly outdated blogs, sites, stackoverflow topics.
On the asp.net site of the project I've found this web.config file: 

<configuration>
<configSections>
  <sectionGroup name="system.web">
 <section name="sanitizer" 
      requirePermission="false" 
      type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, 
        AjaxControlToolkit"/>
      </sectionGroup>
</configSections>
<system.web>
 <compilation targetFramework="4.0" debug="true"/>
 <sanitizer defaultProvider="AntiXssSanitizerProvider">
  <providers>
   <add name="AntiXssSanitizerProvider" 
            type="AjaxControlToolkit.Sanitizer.
              AntiXssSanitizerProvider"></add>
  </providers>
 </sanitizer>
</system.web>
</configuration>


It was similar to the web.config files found on stackoverflow, and IIS was complaining about not finding the AjaxControlToolkit assembly.
After many searches I've found this response on stackoverflow:
"Using AntiXss as the default sanitizer is no longer supported as of June 2012.
From the official announcement, apparantely the new version of AntiXss breaks too many things.".
Oh great! and were was this specified on the http://ajaxcontroltoolkit.codeplex.com/ ?
People don't use the blog of a developer to look for information about a project,
they use the main page of the project, that is the purpose of it, to find out why their
code is not working. And I don't need to mention that the Issue tracker had no
useful information about this.
 
Solution

The solution was to install HTML Agility Pack NuGet package. And make modifications to
the web.config, something like this:

<configuration>
  <configSections>
    <sectionGroup name="system.web">
      <section name="sanitizer" requirePermission="false"
               type="AjaxControlToolkit.Sanitizer.ProviderSanitizerSection, AjaxControlToolkit" />
    </sectionGroup>
  </configSections>
 
  <system.web>
    <sanitizer defaultProvider="HtmlAgilityPackSanitizerProvider">
      <providers>
        <add name="HtmlAgilityPackSanitizerProvider" type="AjaxControlToolkit.Sanitizer.HtmlAgilityPackSanitizerProvider"></add>
      </providers>
    </sanitizer>
  </system.web>
</configuration>

Don't worry about the warning from VS about: "The element system.web has invalid child element..." it will work just fine.

Well, this is it. It is very hard to keep existing documentation up to date, as these technologies change every day, but at least they could made a list of things to keep in mind, to not let situations like this to happen. Nothing is worse than the lack of information when you are facing a problem.
I hope that you have found the solution to your problem in this post.
If you have any questions, suggestions or anything to say, you are welcome to post them as comments.
Until the next time, happy coding :)
ref:
http://terroare.blogspot.com/2013/01/sanitizer-provider-is-not-configured-in.html

Monday, May 12, 2014

unable to access a ajax combobox within a gidview

solution
InvD.LineUsed = ((AjaxControlToolkit.ComboBox)row.FindControl("txtEditLineUsed")).SelectedItem.Text;

MS in Computer Science with paid training in USA company