Tuesday, December 6, 2011

Windows azure assembly not listed under .Net tab

while developing azure application, i stuck with a strange issue.

When i tried to add windows azure assemblies, i was not able to find them under .Net tab on add reference dialogue.

after spending some, I was able to fix this issue. here i have narrated whole problem. hope this can save your time.

Recently I was writing application to rad data from windows azure table storage. I have created windows application to display data from azure table storage.

I need to query data from azure table storage, using windows azure SDK.

These assemblies are:

1) Microsoft.WindowsAzure.Diagnostics
2) Microsoft.WindowsAzure.StorageClient

When I click on Add Reference in my windows application, I was not able to find any assembly in the list of .Net assemblies.

I have tried but not able to find exact reason on this issue. Then after I realized that this was working on my previous application. It was web application.

I have compared all the properties of both the project and find out exact problem.

Cause of problem:

  • In the project properties we have “Target framework” option, when I see for windows application it was set to “.Net Framework 4 Client Profile”. See figure-1.

clip_image002[4]

  • So I was not able see windows azure assemblies under .Net tab.
  • When I inspect my web application, it was set to “.Net Framework 4”. Here I was able to see all windows azure assemblies. See figure-2.

clip_image004[4]

So it was finalized that when there “.Net Framework 4 Client Profile” is selected as “Target framework”, we will not able to reference windows azure assemblies .

Behaviour of this issue:

Because of this setting you can face following issue.

1) You will not able to see windows azure assembly in .Net assembly list.

2) You will not able to reference windows azure assemblies in your application.

3) If you have any class library which includes reference of windows azure assemblies,

And you are trying to add this assembly into your project. Assembly will be added but

It will give you “are you missing an assembly reference?” error.

Resolution:

If you face this issue, you can go to project properties and change “Target framework” To ”.Net Framework 4”.

Microsoft has delivered a new target framework type, to optimize for client applications which run on client only; it doesn’t include windows azure assemblies.

You can see more about .Net Framework Client Profile at

http://msdn.microsoft.com/en-us/library/cc656912.aspx

Wednesday, September 28, 2011

AJAX Control Toolkit 50927 Released for September 2011

A new version of Ajax Control Toolkit has been released.

New version is marked as Release number 50927

New features included

  • Calendar Date Ranges - You can specify a StartDate and EndDate and restrict the dates which a user can select when using the Calendar.
  • Twitter Control -- Display tweets associated with a Twitter user or tweets which match a search query.
  • Gravatar Control -- Display unique images for each user of your website. Users can upload custom Gravatar images at Gravatar.com.

You can find more details on http://ajaxcontroltoolkit.codeplex.com/

Monday, September 19, 2011

Visual Studio 11 Developer Preview with .Net 4.5

Visual Studio 2011 Developer Preview with .Net 4.5 has been announced last week.

New features and improvements in core framework are
  • Ability to limit how long the regular expression engine will attempt to resolve a regular expression before it times out.
  • Ability to define the culture for an application domain.
  • Console support for Unicode (UTF-16) encoding.
  • Support for versioning of cultural string ordering and comparison data.
  • Better performance when retrieving resources.
  • Zip compression improvements to reduce the size of a compressed file.
  • Ability to customize a reflection context to override default reflection behavior through the CustomReflectionContext class.
  • Managed Extensibility Framework
  • Asynchronous File Operations
New Features in ASP.Net 4.5 Developer Preivew are

  • Support for new HTML5 form types.
  • Support for model binders in Web Forms. These let you bind data controls directly to data-access methods, and automatically convert user input to and from .NET Framework data types.
  • Support for unobtrusive JavaScript in client-side validation scripts.
  • Improved handling of client script through bundling and minification for improved page performance.
  • Integrated encoding routines from the AntiXSS library (previously an external library) to protect from cross-site scripting attacks.
  • Support for WebSockets protocol.
  • Support for reading and writing HTTP requests and responses asynchronously.
  • Support for asynchronous modules and handlers.
  • Support for content distribution network (CDN) fallback in the ScriptManager control.

New Features in WCF 4.5 are
  • Simplification of generated configuration files.
  • Support for contract-first development.
  • Ability to configure ASP.NET compatibility mode more easily.
  • Changes in default transport property values to reduce the likelihood that you will have to set them.
  • Updates to the XmlDictionaryReaderQuotas class to reduce the likelihood that you will have to manually configure quotas for XML dictionary readers.
  • Validation of WCF configuration files by Visual Studio as part of the build process, so you can detect configuration errors before you run your application.
  • New asynchronous streaming support.
  • New HTTPS protocol mapping to make it easier to expose an endpoint over HTTPS with Internet Information Services (IIS).
  • Ability to generate metadata in a single WSDL document by appending ?singleWSDL to the service URL.
  • Websockets support to enable true bidirectional communication over ports 80 and 443 with performance characteristics similar to the TCP transport.
  • Support for configuring services in code.
  • XML Editor tooltips.
  • ChannelFactory caching support.
  • Binary encoder compression support
You can get start with Visual Studio 2011 and .Net 4.5 from here.

Tuesday, September 13, 2011

Web Forms Model Binding ASP.Net vNext

We have already checked functionality of Model Binding in next version of ASP.Net. That is not only interesting feature, there is more on it. With Model Binding we can add Value Provider to our method. Value Provider can be Cookie, QueryString, Form or a Control. Your method will look for the Control ID which is your parameter name in method.
For more  details you can checkout below video.

Install Silverlight

An article for the same you can have a look at Web Forms Model Binding Part 2: Filtering Data

Friday, September 9, 2011

jQuery Mobile Beta 3 Released

For mobile web developers, there is a new version of jQuery Mobile has been released.

New version of the jQuery Mobile contains
  • pushState: to enable clean URL ajax based navigation
  • beforechangepage event: to help generate your content at proper time
  • Some issue fixes, etc.
You can download jQuery Mobile Beta 3 from here.

Thursday, September 8, 2011

Web Standards Update for Visual Studio 2010

Hello Readers,

Check out the video below for Web Standards Update for Visual Studio 2010.



This update provides supports for HTML5 and CSS3. Other features included in this update are Image Optimizer and CSS Essentials.

Thanks

Wednesday, September 7, 2011

jQuery Control Toolkit

Hello ASP.Net Coders,

While some of the good site, I came across a very good resource of jQuery Control Toolkit.
This Toolkit come with some extenders, you can customize extender, you can specify Server Control Id as jQuery selector.

You can find more detail for jQuery Control Toolkit on http://jquery.codeplex.com/

Enjoy the coding

Thanks,
Nirav

Friday, September 2, 2011

Strongly Typed Data Controls in ASP.Net

Hello Friends,

In next version of ASP.Net we will get Strongly Typed Data Controls in ASP.Net. With this feature, we can bind a model to our data control and use directly use Model Properties for the binding purpose.

This Strongly Typed Data Controls will aslo help us to avoid simple typing mistakes in binding expression.

You can review link Strongly Typed Data Controls for more details

Thanks

Monday, August 8, 2011

Rendering 3D with CSS and javascript with dom3d

A very good post from James Long on how can we render 3D objects with JavaScript and CSS.

Thursday, June 16, 2011

Static class vs static member vs Singleton

Static class vs Static members


Static Class
Not Static Class with All Static Methods
1.        
This version can’t have instance constructor, and hence we can’t create object of static class. they can contain a static constructor.
This version has constructors and we can create object of this class.
2.        
We can’t pass this class as argument of the method.
We can pass this object as argument.
3.        
You can’t inherit another class in static class.
You can inherit another class.
4.        
Static class can’t be inherited.
This version can be inherited in another class.
5.        
All method and fields inside this call must be static.
Not necessary to make all fields/methods to be static. Though C# does not support static local variables.
6.        
Static class cannot implement interface.
This version can implement interface.
7.        
Method is static class can’t be virtual.
Static method can’t be virtual, we can’t override them.  Static methods can be overloaded but not overridden.
8.        
Use static class to group methods which are not associated with particular objects, for example, we can use static class for utility methods or methods which behaves like fire and forgot.
Use this version, when your method needs to be used as utility method inside the class, for some internal processing.
9.        
The advantage of using a static class is that the compiler can check to make sure that no instance members are accidentally added.
It is more typical to declare a non-static class with some static members, than to declare an entire class as static. Two common uses of static fields are to keep a count of the number of objects that have been instantiated, or to store a value that must be shared among all instances.

Static class vs Singleton
Though both have single instance throughout the application, we can create instance of the singleton instance and can pass it as object in the method, as a result you can use singleton object as normal. This is the huge advantage of singleton over the static class.

Thursday, May 12, 2011

Javascript Mistakes You Must Avoid

Hi Friends,

I have came across a great post on developers making mistakes while writing JavaScript. Please have a look.
http://www.ifadey.com/2011/05/javascript-mistakes-you-must-avoid/

Thanks,
Nirav

Wednesday, May 11, 2011

Ajax Control Toolkit released 50508 version

Hey friends,

A new version of Ajax Control Toolkit is released (50508).
There are some improvments in ModalPopup, AsyncFileUpload and DropShadow controls.

Though you will require Visual Studio 2010 to use new release of Ajax Control Toolkit.

You can download new binaries from http://ajaxcontroltoolkit.codeplex.com/releases/view/65800

Thanks
Nirav

Wednesday, May 4, 2011

jQuery 1.6 released, download now

Hi Friends,

I am happy to share with you all that a new version of jQuery has been released. jQuery 1.6 available to download and on cdn as well.

A few changes in new version are
  • $.holdReady() - this allows user to hold the .ready function until some event
  • .prop() - this allows user to get the value of a property for the first element in the set of matched elements
  • .removeProp() - remove a property from set of element
  • other changes are like, .promise(), deferred.pipe(), deferred.always()
You can find more details for jQuery 1.6 release on jQuery blog http://blog.jquery.com/2011/05/03/jquery-16-released/

jQuery 1.6 is also available on Microsoft CDN you can find out details at http://www.asp.net/ajaxlibrary/cdn.ashx#jQuery_Releases_on_the_CDN_0

Thanks,

Monday, May 2, 2011

LinkButton inside ListView within UpdatePanel cause full postback

Hi Friends,

Today I was creating a listing page with ASP.Net 4.0. I wanted below items on the page

  • A result for my search, I have used ListView for it
  • Inline editing for 1-2 column of my list
  • Edit & Update/Cancel button
    • Generally I am using ImageButton to display Edit/Update/Cancel buttons
    • This time I thought lets use LinkButton, I have also used AjaxControlToolkit’s HoverMenu extender.
  • Apply Ajax on the page, I have placed ListView inside UpdatePanel and set ChildrenAsTriggers as true.

Ok, now I have implemented all the items I required on the page. When I clicked on the Edit link, I was surprised, LinkButton was causing Synchronized Postback (Full page postback). There are many causes where your page do full postback like

  • Page HTML have some unclosed tags
  • there is some JavaScript error
  • You have generated control dynamically but forgot to assign ID to your control

Well I have verified all of them but my problem was different, I was totally confused that how to overcome this issue “I have a update panel, have ChildrenAsTriggers true, Ajax framework is loaded, still my LinkButton causing full postback”

I have given a try, I have converted my LinkButton to Button, everything works fine and page is now doing Partial postback. Now I knew that there is a problem with LinkButton.

By lots of trial and error I figured it out, we need to add

<pages clientIDMode="AutoID"></pages>

ClientIDMode specifies, how will ASP.Net 4.0 generates the id attribute for rendered HTML controls/elements. In previous version of ASP.Net there was not any concept of client id generation, but it was similar to AutoID configuration we have set. Currently default settings for client ID is Predictable.

Hope this will help you to solve your problem

Nirav

Thursday, March 24, 2011

Generate SQL Server Data dictionary

SQL server comes with many built-in Stored Procedures and Views; we know them as system view or stored procedure.

While design of project documentation we often need to generate Dictionary which lists all the tables along with Columns, Data type and Description of columns.

There isn’t any tool or command which Extract this information directly. We can write SQL query using system stored procedures and system views.



1) Using System Stored Procedure.

We have stored procedure called sp_columns. This procedure returns column information for the specified tables or views.

Procedure sp_columns has five parameters. Parameters we are going to use are explained here.



Table_name
This parameter accept name of table without schema, and returns column information.
NULL value of this parameter returns Columns for All tables in the database.
table_owner
Takes owner as argument, if specified will returns columns of tables for that schema only.



Here is the query using sp_columns stored procedure.



declare @ColumnTable table(

TABLE_QUALIFIER varchar(100),

TABLE_OWNER varchar(100),

TABLE_NAME varchar(100),

COLUMN_NAME varchar(100),

DATA_TYPE varchar(100),

[TYPE_NAME] varchar(100),

"PRECISION" varchar(100),

"LENGTH" varchar(100),

SCALE varchar(100),

RADIX varchar(100),

NULLABLE varchar(100),

REMARKS varchar(100),

COLUMN_DEF varchar(100),

SQL_DATA_TYPE varchar(100),

SQL_DATETIME_SUB varchar(100),

CHAR_OCTET_LENGTH varchar(100),

ORDINAL_POSITION varchar(100),

IS_NULLABLE varchar(100),

SS_DATA_TYPE varchar(100)

)

insert into @ColumnTable exec sp_columns null,@table_owner='dbo'



select * from @ColumnTable



2) Using System views.



Some system views returns information about table schema defined in the current database.

sys.columns
Returns a row for each column of an object that has columns.
sys.tables
Returns a row for each table object.
sys.systypes
Returns one row for each system-supplied data type.



We can write following query to returns table column information using system views.



select tab.name, cols.name,typs.name,cols.system_type_id from sys.columns cols

inner join sys.tables tab on tab.object_id =cols.object_id

LEFT OUTER JOIN sys.systypes typs on typs.xtype=cols.system_type_id





You can use any of the option to generate Data Dictionary and then Copy result directly in the EXCEL.

You can refer MSDN for more information about views and stored procedures.

As far as my knowledge there is not any option in Management Studio/Visual Studio to generated Data Dictionary.

If you know any better options please let us know.



Hope this will help.


Saturday, February 5, 2011

ScriptManager.RegisterDataItem to update control outside UpdatePanel

Hi Friends

Today I would like to share an interesting stuff with Ajax. I have seen many of my colleague to use 2 Different UpdatePanel when they want to update a DataBind control and just a single value on the page but outside of UpdatePanel.

Consider a scenario where you are creating a sample application to provide comments threading. And main thread will show total number of comments. Check the sample layout if as below.

image

So here we have a main thread on the top, below that Total Comments which needs to be updated. There are many ways to do this.

1. Put whole page in UpdatePanel. Each and every content will be updated. This is the easiest way.

2. Put the repeater  of comments and Textbox in one UpdatePanel and Total comments in another UpdatePanel. (In this simple layout we may not require, but in real life scenario we have much more complex layout where it could not be possible every time)

3. As we just want to update number of comments in a label. We can use ScriptManager.RegisterDataItem method.

ScriptManager.RegisterDataItem method have 2 override signatures.

1. ScriptManger.RegisterDataItem(Control control, string dataItem)

2. ScriptManager.RegisterDataItem(Control control, string dataItem, bool isJsonSerialized)

This method can be accessed from instance of ScriptManager.

Here is the use of each parameter

control: You need to pass your control for which you are registering the data item

dataItem: String value which will be passed as value to your script manager on client side.

isJsonSerialized: With this Boolean value you can specify that whether string value which you have set as data item is serialized as JSON format.

 

Now, how  does this RegisterDataItem works. RegisterDataItem register a data key and its value while responding to your asynchronous request. Now on client side you need to handle pageLoading event of the script manager.

Here is the code which we will write to achieve output as screenshot.

HTML required

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<table>
    <tr>
        <td>
            Hi this is main thread users are commenting on this post.
        </td>
    </tr>
    <tr>
        <td>
            Total Comments:
            <asp:Label ID="lblShowData" runat="server" Text="0"></asp:Label>
        </td>
    </tr>
    <tr>
        <td>
            <asp:UpdatePanel ID="updData" runat="server">
                <ContentTemplate>
                    <table>
                        <tr>
                            <td>
                                <asp:Repeater ID="rptComments" runat="server">
                                    <HeaderTemplate>
                                        <ul>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <li>
                                            <%# Container.DataItem %></li>
                                    </ItemTemplate>
                                    <FooterTemplate>
                                        </ul></FooterTemplate>
                                </asp:Repeater>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:TextBox ID="txtData" runat="server" TextMode="MultiLine"></asp:TextBox>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <asp:Button ID="btnSubmit" Text="Submit" runat="server" OnClick="btnSubmit_Click" />
                            </td>
                        </tr>
                    </table>
                </ContentTemplate>
            </asp:UpdatePanel>
        </td>
    </tr>
</table>

JavaScript to handle pageLoading event and set data

var pageReqManger = Sys.WebForms.PageRequestManager.getInstance();
pageReqManger.add_pageLoading(OnPageLoading);
/// To execute on page loading while async postback
function OnPageLoading(sender, args) {
    var dataItems = args.get_dataItems();
    if ($get('lblShowData') !== null)
        $get('lblShowData').innerHTML = dataItems['lblShowData'];

}

In javascript we have firstly retrieved the instance of our script manager. Then we have added pageLoading hander. Now when this handler is called you can get the dataitems in the arguments. So we have get the data item for lblShowData and assign it as innerHTML of the control.

C# code for store and binding

public List<string> Comments
{
    get
    {
        List<string> lstComments = Cache["keyComments"] as List<string>;

        if (lstComments == null)
        {
            lstComments = new List<string>();
            Comments = lstComments;
        }
        return lstComments;
    }
    set { Cache["keyComments"] = value; }
}

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        lblShowData.Text = Comments.Count.ToString();
        rptComments.DataSource = Comments;
        rptComments.DataBind();
    }
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
    // Add comment to list
    Comments.Add(txtData.Text);

    //Bind list to repeater
    rptComments.DataSource = Comments;
    rptComments.DataBind();

    // register data item to scriptmanager
    ScriptManager1.RegisterDataItem(lblShowData, Comments.Count.ToString());

    // set the string empty
    txtData.Text = string.Empty;
}

We have registered the data item in click event of the button. With our ScriptManager1 for lblShowData with the values of our total comments. As we only have simple number to display we have not pass the third parameter for json serialization.

If we think of more scenario we can use this method in many ways.

Let me know in case you have query on this method.

Thanks

Nirav

Friday, January 21, 2011

jQuery UI 1.8.9 Released today

Hello Friends,

Its good to know that a new version of jQuery UI has been released today. Released version is jQuery UI 1.8.9.

The change log mainly contains fixes over Draggable and Sortable interactions. Fixes on Accordion, Datepicker and Tabs widgets. There are also localization addition in Datepicker widget.

You can find more detail on below link.

jQuery UI 1.8.9

Thanks

Nirav

Technorati Tags: