RSS

Category Archives: ASP.NET

ASP.NET is a web application framework developed by Microsoft to allow programmers to build dynamic web sites and web applications.

What is error AjaxControlToolkit.CommonToolkitScripts ?


In asp.net application, check below ASP.NET HTML and Javascript code

Problem case:

<aspext:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
      <Scripts>
           <asp:ScriptReference Name="AjaxControlToolkit.Common.Common.js" Assembly="AjaxControlToolkit" />
           <asp:ScriptReference Name="AjaxControlToolkit.ExtenderBase.BaseScripts.js" Assembly="AjaxControlToolkit" />
      </Scripts>
</aspext:ToolkitScriptManager>
<asp:Panel ID="Panel1" runat="server" ClientIDMode="Static" />

<script type="text/javascript" language="javascript">
      function getPosition() {
           var commonObj = new AjaxControlToolkit._CommonToolkitScripts();
           $common.setBounds($get("Panel1"),
           {
                x : 100,
                y : 200,
                width : 200,
                height : 100
           }
      }
 </script>
The assembly 'AjaxControlToolkit, Version=4.1.40412.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e' does not contain a Web resource that has the name 'AjaxControlToolkit.Common.Common.js'. Make sure that the resource name is spelled correctly. Make sure that the application references the correct version of an ASP.NET AJAX Framework assembly

Possible Solution:

1. Try using ScriptManager instead of ToolkitScriptManager as below

<asp:ScriptManager ID="ScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Name="AjaxControlToolkit.Common.Common.js" Assembly="AjaxControlToolkit" />
                <asp:ScriptReference Name="AjaxControlToolkit.ExtenderBase.BaseScripts.js" Assembly="AjaxControlToolkit" />
            </Scripts>
</asp:ScriptManager>

2. Check the version of your ASP.NET application, because above scripts are for .NET 3.5 sp1 as mentioned here on www.asp.net.

Reference from my answer on StackOverflow

 
 

Tags: , , , , , ,

How to convert an IEnumerable to JSON


.Net Framework Logo

You can do it like this using .NET Framework itself and without using any 3rd party tools

using System.Web.Script.Serialization;

public class Json
{
    public string getJson()
    {
       // some code //
       var products = // IEnumerable object //
       string json = new JavaScriptSerializer().Serialize(products);
       // some code //
       return json;
    }
}

Serializing Usage:

IEnumerable<int> sequenceOfInts = new int[] { 1, 2, 3 };
IEnumerable<Foo> sequenceOfFoos = new Foo[] { new Foo() { Bar = "A" }, new Foo() { Bar = "B" } };

var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
string outputOfInts = serializer.Serialize(sequenceOfInts);
string outputOfFoos = serializer.Serialize(sequenceOfFoos);

Output:

[1,2,3]
[{"Bar":"A"},{"Bar":"B"}]

Deserializing Usage:

IEnumerable<int> sequenceOfInts = serializer.Deserialize<IEnumerable<int>>(outputOfInts);
IEnumerable<Foo> sequenceOfFoos = serializer.Deserialize<IEnumerable<Foo>>(outputOfFoos);

Reference links: StackOverflow.com

 
1 Comment

Posted by on January 25, 2012 in .NET, ASP.NET, C#, JavaScript

 

Tags: , , , , , , , ,

Printing in IIS using ASP.NET or Web services


You can try as below:

1. Changing the account that ASP.NET runs under.

The IIS Worker Process runs as Network Service and the ASP.NET Worker Process runs as ASPNET by default. So to access the Installed Printers you have to change it to run under Local System Account.

2. You can impersonate the asp.net site

When the IIS Worker Process or the ASP.NET Worker Process starts a Web application, the Web application inherits the identity of the process if impersonation is disabled. (Impersonation is the process of allowing a thread to run under a different account from its process.) However, if impersonation is enabled, each Web application runs under the user account that is authenticated by IIS or the user account that is configured in the Web.config file. Impersonation can be enabled in either of the following two ways in Web.config:

<identity impersonate="true"/>

This allows the Web application to run using the identity that was authenticated by IIS.

<identity impersonate="true"
 userName="SomeUserAccount"
 password="SomePassword"/>

This allows the Web application to run using a specific identity.

If you have the network printer in my printers then it will show up in Installed printers.

Reference links: Stackoverflow.com and Bluevisionsoftware.com

 
5 Comments

Posted by on January 24, 2012 in .NET, ASP.NET, C#, IIS

 

Tags: , , , , , , , , , , ,

How To: show loading or progress message in website in ASP.NET


ASP.NET Display “Loading…” message while update panel is updating

You can use code as below when

using Image as Loading:

 
<asp:UpdateProgress id="updateProgress" runat="server">
     <ProgressTemplate>
            <div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
                    <asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/images/ajax-loader.gif" AlternateText="Loading ..." ToolTip="Loading ..." style="padding: 10px;position:fixed;top:45%;left:50%;" />
            </div>
     </ProgressTemplate>
</asp:UpdateProgress>

using Text as Loading:

 
 <asp:UpdateProgress id="updateProgress" runat="server">
         <ProgressTemplate>
                <div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
                      <span style="border-width: 0px; position: fixed; padding: 50px; background-color: #FFFFFF; font-size: 36px; left: 40%; top: 40%;">Loading ...</span>
                </div>
         </ProgressTemplate>
    </asp:UpdateProgress>


Reference: StackOverflow.com
 
Leave a comment

Posted by on January 23, 2012 in .NET, ASP.NET, CSS, JavaScript

 

Tags: , , , , , , , ,

How To: Set Image button as default button


<asp:Panel id="pnl" runat="server" DefaultButton="imagebutton1">

// Some of your controls and code //

<asp:ImageButton id="imagebutton1" runat="server" ImageUrl="images/imge.gif" >
</asp:ImageButton>


// Some of your controls and code //

</asp:Panel>


Reference: StackOverflow.com
 
Leave a comment

Posted by on January 23, 2012 in .NET, ASP.NET, C#, JavaScript

 

Tags: , , , , , , ,