.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Ajax enabled user control

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :ASP.Net
Hello all, I've just started to play around with MVC 2. The purpose of it is to evaluate the effort for our team to switch from ASP.net Forms to MVC. The start was quite simple. At the moment the MVC pattern and its implementation (conventions, etc.) is understood it seems to be simpler to get an application running in MVC then in Forms.   In one of our upcoming projects we have to build an Ajax enabled UI. We already work with the jQuery so it will be the library of our choice. The controls we have to build are more or less complex and most of them are based on a domain entity for which we have a class in our domain model.   Now I am wondering what might be the best way to build our ajax enabled user controls.   I have read a few tutorials and blogs about two potential options:   1. Extension methods for HtmlHelper 2. Partial views and Html.RenderPartial   Option 1 is interesting because we pass typed parameters to a method and the output is a HTML string.   Option 2 is interesting because we have way more possibilities to hook into behaviours of control / page rendering.   It would be interesting for me if you could share best practices.   Thanks in advance   nofxmojo

View Complete Post

More Related Resource Links

how to implement user rating using ajax rating control from database?

Hi,I'm beginner to ajax. I've a database table having fields rating and item id.I've to display star rating using  ajax rating control for the corresponding item id.How can i do this?  

AJAX tabcontainer, User Control and Sharepoint UserProfile

Hi All, I am working on following requirement. There is AJAX control, tabcontainer which is added in a user control which inturn is loaded in a sharepoint web part. Controls added int the tabcontainer include textboxes, a drop downbox and a button.On Page load I am connecting to sharepoint logged in user profile and display the information in the tabcontainer. I have kept provision to change the values for some fields which the user can change. On click of submit button the data should get saved to the same user profile and the tabcontainer should get refreshed with the new values entered. Problem Faced: On Page load all the values get populated to the controls placed in tabcontainer. But when I do any change in the control and click on submit, the changed values are not getting displayed instead old values are retained. Please help me in handling postback event. Following is the piece of code on page load and submit button protected void Page_Load(object sender, EventArgs e)         {             using (SPSite ospSite = new SPSite("http://omistestsrv:1995"))             {                 try           

Ajax, Smart Parts(web part w/ ajax support), User Control, and a GridView


So I am playing around with a user control that I created that adds some functionality to a SPList. I have scoured the web looking for a way to get a web part that had a gridview with custom buttons that is bound to certain Items in a sharepoint list. I found Smart Parts and created an Ajax enabled User Control. the problem is that the label is updating but the gridview is not. and on a site note how can I format the Time on Board column to not include milliseconds(the fields are showing up like '1.02:48:31.8633636') i just want 1.02:48 and maybe the 31:

here is my ascx:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AlertControlWebPart.ascx.cs"
  Inherits="AlertControlWebPart.AlertControlWebPart, AlertControlWebPart, Version=, Culture=neutral, PublicKeyToke

Ajax Enabled Gridview using JavaScript in ASP.NET

Before explaining the article, I would like to thank all readers who read my article and voted for it. Your appreciation for my article gives me strength to write more good articles. Hope in future I will get your valuable comments and suggestions. Now I won't waste your time and come back to the topic. I have written this article on 'Ajax Enabled Gridview Using JavaScript in ASP.NET'. In this article, I will show you how to make a Gridview using a simple HTML table, JavaScript and XML HTTP for Ajax call without using any ASP.NET control.

Using Code

GridView Multiple Filter AJAX Control

This AJAX control enables the user to filter data within any column inside a GridView. The user can add multiple filters and can delete existing ones too.

Choosing Between a User Control or Web Part for SharePoint

SharePoint will only display Web Parts on a page. However, there are publicly available shims that allow you to write user controls and have them be displayed as a Web Part. From SharePoint's point of view, the shim is a Web Part. From the point of view of the user control, the shim is simply a control in .NET that is including the user control

watermark textbox using Ajax control

This is pretty simple compared to jquery. Since we need refer a dll only. we dont want any script for this. we just include that reference into our website.

Building Re-Usable ASP.NET User Control and Page Libraries with VS 2008


I am having problems with a user control. I want my solution to have a separate project for holding my user controls.

The main project can get a reference to this user control project and can import this user control dll into my main project. 

Thanks in advance,

Dheeraj Mittal


Multiple Instances of User Control


I have a user control that I place on a page severl times.  When I make a selection on a ddl in one one control the SelectedIndexChanged event fires for all the control on the page for that ddl.  So I get duplication of an insert that I do.  Is there a way to make sure these events are isolated so this doesn't happen.


how to get an array of all the asp.net textbox control inside create user wizard control?



How can I get all the textboxes inside a create user wizard control using getElementsByTagName().

Below is my JQuery code:

<script type="text/javascript">
        function addLoadEvent(func) {
            var oldonload = window.onload;
            if (typeof window.onload != 'function') {
                window.onload = func;
            } else {
                window.onload = function() {

        function prepareInputsForHints() {
            var inputs = document.getElementsByTagName("asp:TextBox");
            for (var i = 0; i < inputs.length; i++) {
                inputs[i].onfocus = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "inline";
                inputs[i].onblur = function() {
                    this.parentNode.getElementsByTagName("span")[0].style.display = "none";



<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

VWDE 2010 Won't Install Ajax Control Toolkit on XP Pro


To my displeasure I cannot find VWD2005 which at one time would generate a complete web.config for Ajax so I downloaded and installed VWDE 2010 to a clean install of XP Pro.

I've created a new tab on the toolbar for the controls but after I select the Ajax dll to add the controls to the toolbar it grinds away and then goes poof and closes down the task leaving VWD look as if I had never even created the tab in the toolbar. 


Any advice here?

Persist data in a dynamically populated ListBox in a user control


Hi All,

I am trying to persist data in a dynamically populated ListBox in a user control. Here are the details

I have a user control which contains a a listBox and button. On Page_Load of user control I am populating the ListBox control with some values. On Click of button, I am trying to fetch the values which I have selected in ListBox. Though this seems very simple and straight forward I am unable to fetch values.

My Page_Load Function

void Page_Load(object sender, EventArgs e)










My Click Function

Protected Void Button1_Click(object sender, EventArgs e)


       string strValue = listBox.SelectedValue



I have placed brake point at Page_Load and on click function, I am seeing that the moment the breakpoin

Category attribute of user control property does not work correctly in categories tab.



I have a User Control (ascx) and a property which a want to display in my categories tab in Visual Studio in the category named "Styles".

[Category("Styles"), DefaultValue(""), Description("The value for formating something.")]
public String MyFormatProperty
set { /* the code for set */; }
get { /* the code for get */; }

And here is the problem: Actually I do not need a get, because I only have to set the property (write only property). But when I omit the get, the property is displayed in the "Misc" category in the categories tab in Visual Studio. Only when I code the get as well, then the property is displayed correctly in the "Styles" category in the categories tab in Visual Studio.

Does anybody know why? How can I display the category correctly only with set?

Thanks, S.

OnItemCommand not firing in Templated User Control


I have a templated user control with single instance template attribute. It works great for everything except the following scenario:


    <asp:UpdatePanel ID="upDirectoryBrowser" runat="server">
        <asp:AsyncPostBackTrigger ControlID="fsBrowser" EventName="FolderSelected" />
        <asp:AsyncPostBackTrigger ControlID="flsBrowser" EventName="FileSelected" />
        <asp:AsyncPostBackTrigger ControlID="flsBrowser" EventName="LinkSelected" />
        <table width="100%">
                <td style="width: 230px;">                        
                    <ntc:FolderSelector ID="fsBrowser" runat="server" OnFolderSelected="fsBrowser_FolderSelected"
                    OnControlException="fsBrowser_ControlException"  /> 
                    <ntc:FileSelector ID="flsBrowser" runat="server" OnFileSelected="flsBrowser_FileSelected"
                    OnControlException="fsBrowser_ControlException" O

"Type ASP.x is not defined" error for dynamic user control when publishing updateable


I have a user control (ContainerCtrl) which programmatically instantiates another user control (SimpleCtrl) in OnLoad. It builds and runs fine, but when I publish it I get the error "error BC30002: Type 'ASP.SimpleCtrl' is not defined." (If I publish without the "updateable" option there's no error, but I need the site to be updateable.)

I assume this has to do with the particulars of how the assembly(ies) are built for the different compiler options. My question is, how can I get it to work properly for "updateable" publishing?

VS 2008 / .NET 3.5 sp1

The code follows (web.config is the default from Visual Studio).

Many thanks, Dave


<%@ Control Language="VB" ClassName="SimpleCtrl" CodeFile="SimpleCtrl.ascx.vb" Inherits="_SimpleCtrl" %>

    Simple control


Partial Class _SimpleCtrl
    Inherits UserControl

    'Nothing to see here.

End Class


<%@ Control Language="VB" CodeFile="ContainerCtrl.ascx.vb" Inherits="_ContainerCtrl"

Cutting Edge: Managing the User Experience in AJAX


This month Dino takes a look at limitations and UI issues in Partial Rendering AJAX pages and techniques for managing the UI.

Dino Esposito

MSDN Magazine November 2007

Least Privilege: Teach Your Apps To Play Nicely With Windows Vista User Account Control


User Account Control in Windows Vista keeps the OS safe from intentional and accidental configuration changes.

Chris Corio

MSDN Magazine January 2007

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend