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

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

Accessing Custom Property in HTML???

Posted By:      Posted Date: September 20, 2010    Points: 0   Category :ASP.Net

i have a usercontrol with a few dropdownlist....n i am using that usercontrol in few pages and depending on pages those dropdownlist  can be enabled mode or disabled mode.

so i created a property:

private string _readOnly;
        public string ReadOnly
         set {
                if (value == "true")
                    ddlOTime.Enabled = false;

Now i am accessing in HTML as

<uc3:OpenTime ID="OpenTime1" OTime='<%#Bind("OpeningTime")%>' ReadOnly="true" runat="server" />

it seems to work.

Just curious know that am i going in right direction or any better approach is available?


View Complete Post

More Related Resource Links

Accessing Property Value of a Custom Control by another Custom Control in Design-time



I created an Extender which has a custom property that drills down a list XML elements from an xml file, where users can select xml elements during design-time. This works perfectly fine. However, my code only has a hardcoded xml filename (source of the xml elements list) and I need to change this by maxing the xml file user-specified.

What I did is that I created another control (panel) which has a custom property that when clicked (through the ellipsis), it will allow a developer to select the xml file which is supposed to be the source xml file that the Extenders shall use. The filedialog from custom panel's property works perfectly fine.

However, my problem now is that when I drag-drop my Extender, I cannot find a way to get the property value of the custom Panel Control which contains the xml filename. I tried creating a static variable which I thought the custom controls can share but VS2010 is breaking.

Please take note that my problem is on Design-time, asp.net.

Appreciate any help. Thanks a lot.

Dhon Nuevo.

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





Using Dynamic Property inside Html Helper with Razor fires an error



I have the following with Razor:

@Html.GoogleAjax(View.GoogleAjaxKey, new String[,] { { "jquery", "1.4.2" } })

And the I get a strange error:

  'System.Web.Mvc.HtmlHelper<object>' has no applicable method named 'GoogleAjax' but appears to have an extension method by that name. Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.

What is strange is that it works fine using:

@Html.GoogleAjax("123", new String[,] { { "jquery", "1.4.2" } })

I tried the following code line:


And the key is displayed just fine so the problem is how I use the value of @View.GoogleAjaxKey into Html.GoogleAjax.

Do I need to change something on my Html Helper? Here it is:

    public static MvcHtmlString GoogleAjax(this HtmlHelper helper, String key, String[,] libraries) {


Unable to search Custom User Property Created in User Profiles in SharePoint 2010


Hi ,

I have created a custom user property,and created metadata property and added mapping to it, still i m not able to Search in People,Please advise

Html.RenderPartial appears to be stripping Model of custom attributes



I have implemented a custom ModelMetadataProvider so that I can decorate my view models with some custom attributes and everything was working fine until I made use of a Partial View.

The following code in my view works fine: -

<%: Html.DisplayFor(x => x.Results) %>

Results is a List which renders a custom display template and is also decorated with a custom attribute.  Using breakpoints, after the above line and prior to the code within the custom display template, the overridden CreateMetadata method in my custom ModelMetadataProvider is invoked.  If I look at the attributes collection parameter I can see that it does contain my custom attribute thus everything working as expected.

However, if I replace the above with the following line of code in my view then it breaks: -

<% Html.RenderPartial("ApplicationSearchResults", Model.Results, new ViewDataDictionary()); %>

All the Partial View contains is: -

<%: Html.DisplayFor(x => x) %>

Again using breakpoints, after the above line and prior to the code within the custom display template, the overridden CreateMetadata method in my custom ModelMetadataProvider is invoked.  But this time if I look at the attributes collection parameter my custom attribute is not there.

Any idea

corrupt html from custom control on win2003/iis6 box


Hello everyone -- first time poster and relative newcomer to the boards.  This bug I'm tackling has me at my wits' end and it's come time to turn to the masses!  If this is posted in the wrong forum and/or has already been addressed, I apologize.  However, I've done thorough searches and haven't come across anything akin to what I'm facing.

I'm working with a website that has a set of custom controls, all descending from a base class.  These controls take DataSets returned from web services and renders custom html via overriding the Render method.  Everything works fine on my local box and my coworker's box (both xp machines running iis 5).  However, on our server (windows server 2003, 64-bit, iis 6), the html rendered by the browser appears corrupt, with garbage replacing individual characters, as follows:


Problem in Custom Control Unable to find Control To Validate Property


I make a custome control by taking a TextBox and A Regular Expression Validator.When i Use this on a .aspx page it works fine.But when i use this on .ascx page and dynamically load user control on a place holder in .aspx page it through an Error

Unable to find control id '_ctl0:txtEmail' referenced by the 'ControlToValidate' property of '_ctl0:txtEmailRequired'


My Custome control Code is this"--

public class EmailValidator:System.Web.UI.Control, INamingContainer{

private System.Web.UI.WebControls.TextBox textBox;

private System.Web.UI.WebControls.RegularExpressionValidator regularExpressionValidator;

public EmailValidator(){

textBox = new TextBox();

regularExpressionValidator = new RegularExpressionValidator();

IsErrorTextBelow = true;

IsRequired = false;

DateTime custom managed property search fails with " Your query is malformed. Please rephrase your q

I've created a front end search page in Silverlight 4 for SharePoint Search.  Currently we are using WSS 3.0 + Search Server Express 2008 (v  The page interacts with the MOSS version of the search web service at:   <site collection>/_vti_bin/search.asmx The reason for this approach is the unique way the requirements specify the look and behavior of the results.  The built-in Search Center page or web parts will not satisfy these requirements. We are going into production but I still cannot figure out how to search against my custom managed properties that are of Type DateTime.  If I cannot get this to work, it is a showstopper. I've tried numerous variations on the SQL Syntax and cannot get it to work.  I know the error is in the date portion of the WHERE clause since I can remove it and searches work fine. Here is a working query: SELECT Size, Rank, Path, Title, Description, Write, RequestSubmittedDate, DocumentType, RequestPromisedDate, ProblemDescription, DatePublished, RequestOwner, RequestingDepartment, DocumentAuthor, ProjectNumber, ProjectDescription, RequestStatus FROM scope() WHERE CONTAINS ('"nmr"') ORDER BY "Rank" DESC yet if I try to use a date literal in the WHERE clause as in the following query modification, I get the "malformed"

Validating Custom Types and Html.EditorFor() Templates?

I'm finding my self with the problem that if I do not show the Template for a "complex" object I have in the main view object I still get the errors in the summary. How do i get around this? I've got a model with say:   HouseType ->Persons (has its own editor template) ->Pets(has its own editor template)   In the create view I show each one depending if they are not null. But when I try to validate HouseType and say I have Persons not null and pets is null. I get errors of validation for pets. How do I get around this? -Thanks

Custom Field - SP is creating HyperLinks and using HTML entities

Hello. I'm seeking help with a problem related to a custom field in SharePoint 2010. Our Custom Field builds upon (extends) the SPFieldMultiLineText field. Data saved to our Custom Field is being processed by SharePoint before it is sent to the client. For example < and > is replaced by HTML entities (&lt; and &gt;). Text such as http://bing.com and mail@bing.com is automatically being converted to hyper links (<a href="mailto:mail@bing.com">mail@bing.com</a>). Is it in any way possible to have SharePoint deliver the data as it was stored in the custom field? We don't want it to replace HTML with HTML entites, nor should it create hyperlinks automatically. I have attached our XSL file below. <xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Micros

Accessing a public property of a nested user control in a master page from a pages' user control

Hi  I've got a web site that has a master page and that master page (mpMaster that has a user control (ucControl1) which has a sub user control (ucControl2), this user control has a property which accepts a value. Now, I have a page that uses the master page and on this page I have another user control (ucPageControl), I need to  find a way of setting the value in ucControl2 from ucPageControl. Is this possible at all? Many thanks Ed

How to exclude one of model's property from the Html.EditorFor

Hi, I would like to exclude one of model's property from the Html.EditorFor. I tried  [HiddenInput(DisplayValue=false)]  but it renders the property as an hidden input. This could potentially be a security problem. How can we completely exclude a field from Html.EditorFor? Thank you,Max

Custom Workflow Activity dependency property FieldNames

I have a custom actvity in VS2008. All is well until I added a new dependancy property like so: public static DependencyProperty EventLookupColumnNameProperty = DependencyProperty.Register("EventLookupColumnName",typeof(string),typeof(FTFSyncEventToAttachmentListItem)); public static DependencyProperty EventLookupColumnIDProperty = DependencyProperty.Register("EventLookupColumnID",typeof(string),typeof(FTFSyncEventToAttachmentListItem)); [Description("Event Lookup Column Name")][DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)][Browsable(true)][ValidationOption(ValidationOption.Required)]public string EventLookupColumnName{get { return ((string)(base.GetValue(EventLookupColumnNameProperty))); }set { base.SetValue(EventLookupColumnNameProperty, value); } [Description("Event Lookup Column ID")][ValidationOption(ValidationOption.Required)][Browsable(true)][DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]public int EventLookupColumnID{get { return ((int)(base.GetValue(EventLookupColumnIDProperty))); }set { base.SetValue(EventLookupColumnIDProperty, value); }}Then in the actions file:    <Action Name="FTF Sync Event To Attachment List Item"   ClassName="DP.Sharepoint.Workflow.FTFSyncEventToAttachmentListItem"   Assembly="DP.Sharepoint.Workflow, Version=, Cultur

Accessing Property of Webpart

Hello All   I am having one scenario where i need to access property of webpart1 in webpart2 Example : Webpart1 has property max records to display which user sets from UI side and fetch data from list upto the property set. Webpart2 also needs to display records from the same list used in webpart1 but there records displayed should be records after displayed in webpart1. i.e. if webpart1 displays records as (1,2,3) then webpart2 should display records as (4,5,6). So please let me know how i can access property of webpart1 in webpart2   I would be thankfull for any reply   Thanks & Regards Mrugank Dholakia

Creating custom property on derived Page

I am attempting to accomplish the following during the creation of a Page derived from DerivedPage: <local:DerivedPage xmlns="..." xmlns:x="..." xmlns:local="..." MyProperty="My Value" Title="My Title"> ... </local:DerivedPage> You'll notice an extra property MyProperty in there. The code-behind is like this: class DerivedPage : Page { public string MyProperty { get; set; } ... } When I execute this, I get a null reference in InitializeComponent() when I create a Page derived from DerivedPage. I also tried making MyProperty a dependency property.  But I get the same results. How can I create a property for my new base-class that's set in the markup of my derived class. Thanks, ...Matt

Sorting search results by custom managed property


I am customizing the XSLT for the core results webpart to give the user the option to sort search results by a certain managed property. There are several managed properties that I am listing on the search results page, and when the user clicks one, it should sort the results by that property.

In MOSS 2007, you could use the "v=property" parameter in the URL to define the sort order, but this doesn't seem to work anymore in SharePoint 2010. Are there any ideas on how to accomplish 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