.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

Custom Control and DataBinding pb

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :WPF
Just Build a Simple Control with an embeded TextControl(RootTxt) and a Property Contents : Public Class Menu Inherits UserControl Public Sub New() InitializeComponent() VisualStateManager.GoToState(Me, "Normal", False) End Sub Public Shared ContentsProperty As DependencyProperty = DependencyProperty.Register("Contents", GetType(String), GetType(Menu),Nothing) Public Property Contents As String Get Return Me.RootTxt.Text End Get Set(ByVal StrContent As String) Me.RootTxt.Text = StrContent End Set End Property End Class When a Try to Bind Contents with a ressource Property it does not work : EX xmlns:local="clr-namespace:TMTemplate" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <UserControl.Resources> <local:ApplicationResources x:Key="LocStrings" /> </UserControl.Resources> ..... <local:Menu x:Name="menu1" Contents="{Binding Path=Strings.MainPage_SubTitle, Source={StaticResource LocStrings}}" FontFamily="Fonts/Fonts.zip#Genx Package" FontSize="17" Foreground="#FF0A0A0A" RenderTransformOrigin="0.5,0.5" Cursor="Hand">Any Idea bacause it's work q

View Complete Post

More Related Resource Links

Custom web server control - databinding issues


I've created very simple web server control appropiate for the task.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI;
using System.Drawing;

namespace CustomWeb

    public class ValuedLabel : Label

        public string Value { get { return _value; } set { _value = value; } }

        private string _value;

        public string IsMultiSelect { get { return _isMultiSelect; } set { _isMultiSelect = value; } }

        private string _isMultiSelect;


As you can notice, my control extends built-in Label control. I'm adding 2 properties. I've created class library and added .dll to my website's references. I've added my control on ToolBox and put it on .aspx page. What i'm doing with that control is adding it inside ItemTemplate of ComboBox which gets populated with ObjectDataSource.

                         <cc1:ValuedLabel ID="vLabel" runat="server" Text='<%# Eval("Name") %>' Value='<%# Eval("IDCategory") %>' IsMultiSelect='<%# Eval("MultiSelect") %>' ></cc1:ValuedLabel>

Custom Control Design-Time SiteMap Provider Error


Greetings - I was referred here by MSDN forums hope this is the right place -  

I have a custom control (:WebControl) that renders web.sitemap in a specific way. While it runs error free and produces the expected result, at Design-Time it complains

Error Creating Control - MyControl  The provider 'AspNetXmlSiteMapProvider' specified for the defaultProvider does not exist in the providers collection.

I have discovered that the error is cause by this line of code:

string div = string.Format("<div class='{0}' id='{1}'>{2}</div>", this.CssClass, this.ID.ToString(), EnumerateNodesRecursive(SiteMap.RootNode, level));

or more specifically, by the reference to SiteMap.RootNode - I am not clear what is missing thoough because I have configured the SiteMapProvider in web.config as this:

        <add name="AspNetXmlSiteMapProvider" 
             type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" 

video tutorial link for composite and rendered custom server control


hii all

i am new to technology so go easy on this post

according to what i read from web there are 3 type of custom server controls

1 superclass

2 composite

3 rendered

i found video tutorial for superclass custom server control but couldnt find video tutials for other 2.

please forward me link for composite and rendered custom server controls video tutorial  

image inside custom server control



I want to use an image inside a Custom Web server control ! 

Do I need to use Web.resources ? if so , how to do ?

Custom Server Control Property not maintaining state


I have created a server control consisting of a TextArea and a div under it.  My goal is to create my own asp:TextArea type control.  the div is for a Character count of the text area and seems to work ok but i added a CharacterCountVisible property to the control that is always returning true.  See Proptery definition below


<Bindable(False), Category("Appearance"), DefaultValue("True"), Localizable(True)> Property CharacterCountVisible() As Boolean
        Return _CountBoxVisible
    End Get
    Set(ByVal value As Boolean)
        _CountBoxVisible = value
    End Set
End Property

Note the _CountBoxVisible variable is define inside the class as :

Dim _CountBoxVisible as Boolean = True

What I am trying to do is give the user/coder the option to show/utilize the char count feature.  Can make it disappear with textarea1.CharacterCountVisible = False but setting it to true will not make it display.


What am i missing





custom control



i want to create  my own button using server control .cs file ..

it should have background color black and foreground color as lime and also it should have

the eventhandler mechanism when we double click on that..

can u provide a code for that...?

custom control


hi.. i want to create a custom control button and textbox using server control.. if i type the text into the textbox,when i click the button it should go to the next page related to that text...

please can u provide a code for this kind of question 

Custom Control Design view error



I have created a custom control from scratch and it works fine as in you can build the project that uses it and it works fine at runtime. Problem is when you go to design view the control shows an error in the place of where the control should be rendered.

Error: '<SomeValue>' Could not be set to '<SomeProperty>'

This shows up on all my custom set properties. These properties are created as basic as possible. I can give the properties values in Source view and run the app just fine. I can even add a Onclick event. If I don't set any custom properties the control will render fine in Design view. It's only when I set a value to a custom property.

Property Code Example:

public string Text
                string ret = "";
                object obj = ViewState["Text"];
                if (obj != null)
                    ret = obj.ToString();
                return ret;
                ViewState["Text"] = value;

I've even removed the Category and Description tags with no difference.

I don't know if what I said makes sens, but I hope it

Extend ASP.NET: Simplify Data Binding In ASP.NET 2.0 With Our Custom Control


The wwDataBinder control addresses simple control data binding--binding simple form controls like textboxes, checkboxes, and the selected values of list controls to individual data or object values.

Rick Strahl

MSDN Magazine December 2006

Cutting Edge: Custom Data Control Fields


In ASP. NET 2. 0, the GridView and DetailsView controls are designed to work together. They don't merely provide complementary services, they also share a number of helper classes and components. The output of the GridView control consists of a sequence of rows, each with a fixed number of columns.

Dino Esposito

MSDN Magazine January 2006

Custom Field Control


I would like to know how can we build a custom field control in sharepoint. Following is the scenario i am looking into it:

1. Textbox control with browse button

2. When we click on browse button, need to display a popup (like business data dialog box) where i can search for project id from oracle datasource and then select the project id(s) from the search results. Selected project id(s) must be concatenated with colon or semi colon and display back to original text box.

I guess requirement is very clear. Please help me how to do this type of things in sharepoint. I have never done these type of requests earilier. Thank you very much for you help.

viewstate in a custom control

I am having issues with a simple custom control that I created by subclassing the hyperlink control.

I wanted to create a control called BackLink that would automatically grab the referring url to the page when it first loads the page. and on postbacks it would continue to use the initial value

I am able to capture and set the navigateurl property when the containing page first loads just fine but if the page submits to itself, the control loses its navigateurl value.

I have the enableviewstate property set in the aspx page but it doesn't seem to want to keep its viewstate

Am I missing something? Do I have to manage my own ViewState?

here is my code

public class BackLink : System.Web.UI.WebControls.HyperLink

public BackLink()
this.Text = "<< back";

protected override void Render(HtmlTextWriter output)
if (this.Page.IsPostBack == false)
//save back url
Uri _backUri = this.Context.Request.UrlReferrer;

if(_backUri != null) this.NavigateUrl = _backUri.PathAndQuery;

else this.NavigateUrl = "/";

To create a custom control and type while creating a column


HI All,

i am creating a column in the list while creating a column i will have an option for choice field on selecting choice i can see dropdown, radiobutton, Checkbox to select and  can enter list of values. and on clicking ok i will get a column with radiobutton. in newform.aspx and also in editform.aspx

so i need to create the similar functionality with my custom radio button, so on create column i need to show my custom choce on selecting this i need to show my custom radiobutton  and  can enter list of values then on selecting it then click ok to create a column, in edit form and new form i need to show a radio buttons with values.

Thanks in advance




Applying custom CSS to the MOSS 2007 Calendar control Month view



I have a requirement to use the MOSS 2007 Calendar Control - month view is to apply a custom css to have a look and feel as per our requirements.

We tried applying the custom css to the MOSS 2007 calendar control - month view, it does take the custom css and applies it, but when i click on any date and come back to the calendar control, it changes the CSS of the MOSS calendar control back to the default one.

Let me know if anyone has any suggestion on  how to customize the calendar control for css for our intranet application.

Your response would be highly appreciated.






Custom Field Control 'not registered as safe'


Hi all,


my goal is to create a custom field control based on a custom field, to be part of a custom content type which derives from a publishing page. Also I want the custom field control to be part of a custom page layout which is associated with my custom content type.


I followed the steps from Patrick Tisseghems book 'Inside MOSS2007', which includes the following instructions:


  • Create and implement the following classes: CustomField, CustomFieldValue, CustomFieldControl. Sign them and deploy the assembly to the GAC.
  • Create a User Control Custom.ascx. Copy it to Controltemplates directory.
  • Create fldtypes_custom.xml and copy to 12\TEMPLATE\XML
  • Add <SafeControl /> entry to web.config

I did of all the above plus I created a page layout in SharePoint Designer which contains an instance of my CustomFieldControl.


When I create an instance of CustomPage (derived content type from Publishing Page, with extra field of type CustomField) with my custom page layout and add it to the Pages library of my Publishing site, everything seems to go fine. When i edit properties of the page with /Pages/Forms/EditForm.aspx I can even edit the custom field value trough the interface using mu custom field control! Everything seems to work perfectly!


But... this

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