C# - Add A Textnode Instead Of An Attribute In A .NET Configurationsection?

Feb 22, 2011

I currently have a .NET custom configurationsection that looks like this:

<customSection name="My section" />

What I want is to write it as a textnode (I'm not sure if this is the correct term?) like this:

<customSection>
<name>My Section</name>
</customSection>

My current customSection class looks like this:

public class CustomSection: ConfigurationSection {
[ConfigurationProperty("name")]
public String Name {
get {
return (String)this["name"];
}
}
}

What should I do to make it a textnode?

View 1 Replies


Similar Messages:

C# - Specify A Range With The IntegerValidator Attribute On A Custom ConfigurationSection?

Jan 21, 2010

I have a class containing the following ConfigurationSection:

namespace DummyConsole {
class TestingComponentSettings: ConfigurationSection {
[ConfigurationProperty("waitForTimeSeconds", IsRequired=true)]
[IntegerValidator(MinValue = 1, MaxValue = 100, ExcludeRange = false)]

[Code]....

The value for the property 'waitForTimeSeconds' is not valid. The error is: The value must be inside the range 1-100.

If I change the IntegerValidator to have an ExcludeRage = true, I (obviously) get:

ConfigurationErrorsException was unhandled

The value for the property 'waitForTimeSeconds' is not valid. The error is: The value must not be in the range 1-100

If I then change the value of the property in the .config to a number higher than 100, it works.

If I change the validator to just have a MaxValue of 100 it works, but will also accept a value of -1.

Is it possible to use the IntegerValidatorAttribute with a range like this?

Edit to add

Confirmed as an issue by Microsoft.

View 1 Replies

C# - Moq ConfigurationSection?

Dec 8, 2010

my application has the following code:

public interface IConfigurationManager {
CustomSection Settings { get; }
}

[code]...

View 1 Replies

System.Configuration.ConfigurationSection Not Available Under Class Library

Apr 30, 2010

I'm migrating a piece of functionality from my App_Code directory to a separate project that's going to build a class library to be referenced by my web app. One of my classes in the App_Code piece inherits form System.Configuration.ConfigurationSection, like so:

Imports System.Configuration
Imports System.Web.Configuration
Imports Microsoft.VisualBasic
Namespace P10.WebStore
#Region "WebStore Section"
Public Class WebStoreSection
Inherits ConfigurationSection

I absolutely cannot get the project to recognize ConfigurationSection as a class. Nothing I google about this class mentions having to do anything special to use it. Is it because this is a class library and not an .exe or somethign?

View 1 Replies

Web Forms :: Changing From Website To Web Project: With Implementing ConfigurationSection?

Feb 22, 2010

I am using the ASP.NET Web Site Small Business Starter Kit as a starting point for a simple web app. I wanted to convert it to a web project from a web site for few reasons (better interaction with VisualSVN, etc..).

I converted pretty much evertyhing over without too much trouble. Only one page is having an issue - at first the one issue I had on this same Provider: I was getting an error message about the type for the class that inherits ConfigurationSection (ProviderSettingsValidation) could not be found. I did some googling and ofund I had to change the web.config, at the type section for the provider to use the full assembly name/type name instead of just the typename. But after doing this, I get a new error and find myself stuck and found nothing on google... here is unhandled exception message:

An error occurred creating the configuration section handler for SmallBusinessDataProviders: Type 'FooWeb.ProviderSettingsValidation' does not inherit from System.Configuration.IConfigurationSectionHandler'. (C:ProjectsFooWebFacingFooWebFooWebweb.config
line 5)

View 1 Replies

Configuration - Have Settings In The Web.config (and Access Them Using ConfigurationSection) Or In A Separate XML File?

Sep 20, 2010

I have few settings which I could place in a separate XML file and have them accessed in the Web app. Then I thought (thinking of one additional file to deploy), why not have them in the web.config itself. However, just because I need to have custom nodes, I can not have the settings under . So, I am thinking of creating a custom config handler following this. Would that be better than having a separate XML file? Is It going to be an overkill or performance wise? Is there a better way to go?

View 1 Replies

Forms Data Controls :: Attribute 'onchange' Is Not A Valid Attribute Of Element 'TextBox'

Mar 31, 2011

<asp:GridView ID="GridView1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:TextBox ID="TextBox1" onchange="calculate()" runat="server" Text="0"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

I'm getting this error on the above markup: Message 1 Validation (ASP.Net): Attribute 'onchange' is not a valid attribute of element 'TextBox'.

View 2 Replies

Web Forms :: Getting Error / Unrecognized Attribute 'targetFramework'. Note That Attribute Names Are Case-sensitive

Mar 17, 2011

I have a problem with my web site 1stSigBdeAssn.org. I have made no changes to the site but I now get the following error message:

Parser Error Message:

Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive.

Source Error:

[code]....

View 4 Replies

Web Forms :: Attribute 'Master' Not Valid Attribute Of Element 'Control'

Feb 1, 2011

I created a simple Master Page in Visual Studio 2008:

<%@
Master
Language="VB"
CodeFile="MasterPage.master.vb"
Inherits="MasterPage" %>
<!DOCTYPE
html
PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"

and got green underlined 'Master' with two warning messages: 1.Validation (ASP.NET): This attribute name must be followed byan equal (=) sign and a value. If the value is in quotation marks, the quotation marks must match. 2. Validation (ASP.NET): Attribute 'Master' is not a valid attribute of element 'Control'.How I can get rid of the messages?

View 3 Replies

Forms Data Controls :: ListItem Error Message Validation(ASP .Net):Attribute CssClass Is Not A Valid Attribute Of Element ListItem

Sep 17, 2010

I have a tag:

<asp:ListItem
CssClass="LabelCSS">Executive</asp:ListItem>

and I am getting the error message

Validation(ASP .Net):Attribute CssClass is not a valid attribute of element ListItem.

What attribute would I use for Css with ListItem?

View 2 Replies

Configuration :: Unrecognized Attribute "targetFramework" Note That Attribute Names Are Case - Sensitive While Hosting

Nov 29, 2010

i'm trying to host an .net framework4.0 application in IIS7. i got an error while clicking on the manage module in modules .like ("Unrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive. ") .I changed my application poll to .net4.0.I am able to browse my application

</system.serviceModel>
</configuration>

View 5 Replies

Configuration :: Unrecognized Attribute "targetFramework" - Note That Attribute Names Are Case - Sensitive

Oct 20, 2010

I installed Microsoft Visual Studio 2010 Ultimate Trial and converted existing asp.net 2.0 web application and I am getting this error: znrecognized attribute 'targetFramework'. Note that attribute names are case-sensitive. It's coming from this section in the web.config which was auto-generated by VS2010 when I converted the project:

<compilation defaultLanguage="c#" debug="false" targetFramework="4.0">
<compilers>
<!--<compiler language="c#" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" extension=".cs" compilerOptions="/d:DEBUG;TRACE" /></compilers> -->
<compiler language="c#" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" extension=".cs"/></compilers>
<assemblies>
<add assembly="Microsoft.JScript, Version=10.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies></compilation>

View 1 Replies

C# - Retrieve The Name Of The Attribute Dynamically Without Specifying The Name Of The Attribute?

Aug 13, 2010

I am developing asp.net mobile application. I am using LINQ to XML to query XML file. I am using the following query to retrieve the name & value of the query dynamically as follows

var TotalManifolds = from MF in FieldRoot.Element("FIELD-DEFINITION").Element("MANIFOLDS").Elements("MANIFOLD")
join SLT in FieldRoot.Element("FIELD-DEFINITION").Element("SLOTS").Elements("SLOT")
on (string)MF.Attribute("MID") equals (string)SLT.Attribute("PARENT")
select new
{
SlotName = (string)SLT.Attribute("NAME").Value,
SlotValue = (string)SLT.Attribute("NAME").Value
};

In the following statement of above query I want to retrive the name of the attribure dynamically without explicitly specifying the name of the attribute SlotName = (string)SLT.Attribute("NAME").Value Here I am explicitly specifying the name. I want to code which can dynamically retrieve the name of the attribute. I am new to Linq to xml. how this can be done programatically? or can you provide me the link through which I can resolve the above issue ?

View 2 Replies

Security :: Domain Attribute In Web.config Is Unrecognized Attribute 'domain' In Asp.net 1.1

Jan 21, 2011

I am trying to achieve a SSO implimentation across my websites so i am using the machine key attribute to do so.now the trouble starts here as the website the user logs in is on the .net 1.1 framework and the website it it navigating to is .net 4.0.I have share the same machine-key across both the application . It works fine in my testing environment but as i move to the deployment server ,it just dosent work !So what i could do is read this article on MSDN :

http://msdn.microsoft.com/en-us/library/eb0zx8fc.aspx
this tells me to add a domin attribute like below
<forms loginUrl="~Login.aspx" defaultUrl="Default.aspx" protection="All" timeout="80" name=".ASPXAuth" domain="asbc.com"/>
but this thing just dosent work on the 1.1 application and throws an error Unrecognized attribute 'domain'.

Where do i get to mention the domin in my 1.1 application.?

View 3 Replies

How To Add Attribute To Title Tag

Oct 22, 2010

I'm using webforms ASP.NET, with masterpages. I want to add a LANG attribute to the <title> tag. ASP.NET automatically generates a title tag. I've tried adding my own tag with an ID and runat="server", like this:

<title id="titleBlock" runat="server"></title>

When doing this, I can set an attribute like the following without any errors.

titleBlock.Attributes.Add("lang", "it");

However, ASP.NET wipes out my <title> tag completely and puts its own in without my LANG attribute. Is there any way to accomplish this?

View 1 Replies

What Is The Class Attribute And How To Use

Nov 8, 2010

What is the class attribute and how to use

View 1 Replies

Why Value Is Available When Use Code Behind Attribute Add

Feb 18, 2010

I have a TextBox in my page

<asp:TextBox ID="TextBox1" runat="server" ReadOnly="true"></asp:TextBox>

I am not able to get the changed value ( I have attached a ajax calender with this textbox)

in code behind because it is readonly

I can do this using TextBox1.Attributes.Add("readonly", "readonly"); or I can get the correct last value using Request.Form[TextBox1.UniqueID]

Why value is available when use code behind attribute add

View 6 Replies

Add A Value - Less Attribute To A UserControl

Mar 29, 2011

In ASP.NET, you can add custom HTML tag attributes to a UserControl via

myLabel.Attributes['my-custom-attribute'] = "someValue";
// or Attributes.Add()

but how can I add an attribute that doesn't have a value? For example, (and I'm not saying that this is what I need) the W3C specification only needs the checked attribute present in a checkbox to consider it checked (instead of checked='true' or something).

<span ID="ctl-blah-blah-myLabel" my-custom-attribute>some text</span>

I'm looking into using something like this to tag specific elements on my page for some client-side behavior. I know that I can do the same with classes, but (1) classes are iffy to manipulate server-side, and (2) I kind of don't want to pollute my class declarations just for tagging (that may be weird for some, I know).

View 3 Replies

Web Forms :: Extracting Attribute Value From XML?

Jun 7, 2010

This may be something simple, but I am completely new to ASP.NET. I have been reading some tutorials based on W3Schools, and I have copied one of the files and tried to play with it by changing an element with a value to storing that same value in the attribute. Here is the edited XML (my.xml):

<?xml version="1.0" encoding="ISO-8859-1"?>
<countries>
<country>
<text value="N">Norway</text>
</country>
<country>
<text value="S">Sweden</text>
</country>
</countries>

I want to extract the N and S and use them as tooltips. Here is my aspx file:

<%@ Import Namespace="System.Data" %>
<script runat="server">
sub Page_Load
if Not Page.IsPostBack then
dim mycdcatalog=New DataSet
my.ReadXml(MapPath("my.xml"))
my.DataSource=my
my.DataBind()
end if
end sub
</script>
<html>
<body>
form runat="server">
<asp:Repeater id="my" runat="server">
HeaderTemplate>
table border="1" width="100%">
<tr>
<th>Name</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td title="<%#Container.DataItem.("text").Attributes["value"]%><%#Container.DataItem("text")%> </td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
</body>
</html>

What have I missed here?

View 6 Replies

Web Forms :: More Than One Attribute Allowed?

Jul 19, 2010

Why in asp.net web page we have only one FORM attribute, but in other language more than one FORM attribute is allowed.

View 3 Replies

XMLNode Add Attribute Without Prefix

Jan 26, 2011

I have the following method:

Code:

XmlNode AttributeNode = xmlDocument.CreateNode(XmlNodeType.Attribute, fieldName, WILTSNAMESPACE);
AttributeNode.Value = fieldValue;
parentNode.Attributes.SetNamedItem(AttributeNode);
this create (for example):
<Person d2p1:PersonRole="Boss">

How do I add an attribute without the d2p1: prefix:

<Person PersonRole="Boss">

View 5 Replies

Possible To Set AssociatedControlID Attribute Using JQuery

Apr 7, 2010

Is it possible to set "for"(AssociatedControlID) attribute using jQuery? I am trying something like this to set it to the very next control that appears after label:

$('label.asssociateClass').each(function()
{
var toAssociate = $(this).next(':input');
$(this).attr("for", toAssociate.attr("id"));
});

The problem is that if I don't set it on a server through AssociatedControlID it never gets here since it's rendered as span instead of label in that case. Is there a way to overcome this or I have to do it on a server?

View 2 Replies

MVC :: DataAnnotation Attribute For Integers?

Jan 11, 2011

Is there an out-of-the-box DataAnnotation attribute that checks if an integer is greater than a certain value?

public Model
{
[GreaterThan(0)]
public int MyVal{get;set;}

}

View 4 Replies

C# - Caching Attribute For Method?

Mar 16, 2011

Maybe this is dreaming, but is it possible to create an attribute that caches the output of a function (say, in HttpRuntime.Cache) and returns the value from the cache instead of actually executing the function when the parameters to the function are the same?

When I say function, I'm talking about any function, whether it fetches data from a DB, whether it adds two integers, or whether it spits out the content of a file. Any function.

View 5 Replies

How Does The ApplicationName Attribute Actually Work

Dec 20, 2010

why did asp.net team choose / as the default value of Membership Role application name rather than the project name that makes sense?

In addition, the application might not be deployed as the root application. It means that / is no longer

Edit 1:

For example: I create a project A first and deploy it. Later I create another project B and deploy it. If both projects use the default, they still work but it will be difficult to know which users come from each project.

For me, it is better if the default is set to the project name.

Edit 2:

I am talking about the applicationName attribute generated by Visual Studio in Web.config.
Why don't use the project name instead of / by default ?

<membership>
<providers>
<clear />
<add name="AspNetSqlMembershipProvider"
type="System.Web.Security.SqlMembershipProvider"
connectionStringName="ApplicationServices"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5"
minRequiredPasswordLength="6"
minRequiredNonalphanumericCharacters="0"
passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider"
type="System.Web.Profile.SqlProfileProvider"
connectionStringName="ApplicationServices"
applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear />
<add name="AspNetSqlRoleProvider"
type="System.Web.Security.SqlRoleProvider"
connectionStringName="ApplicationServices"
applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider"
type="System.Web.Security.WindowsTokenRoleProvider"
applicationName="/" />
</providers>
</roleManager>

EDIT 3:

After creating two applications (i.e., one as the root and the other one as the child app) and both have the same applicationName set to /, both application use the same ApplicationID. It means the slash has nothing to do with site domain tree. My confusion has been answered. So... why did Visual Studio set it to / (that makes confusion for me) by default?

EDIT 4:

I have two applications. One as the root application and the other one as the sub application under the former. Both use applicationName = "/". I got the result as follow in database: So what is the meaning of /? If no meaning, why did VS choose this confusing name rather than the project name?

EDIT 5:

From this article, I will make the summary:

If we remove applicationName attribute from web.config for both applications, the ApplicationName generated in database for the root will be "/" and the ApplicationName generated in database for the sub app will be "/subappvirtualdir".If we leave the applicationName to its default value of "/" for both applications, both root app and sub app will get the same ApplicatonName of "/" generated in database. If we change the applicationName to "any name you want" for both applications, the ApplicationName generated in database will be set to "any name you want" for both applications.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved