.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

Odd issue with createuserwizard--can't see controls I add to template in code behind in .net 4.0

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

I was able to customize the createuserwizard in .net 3.5 with no problems.  I could add controls like the dropdownlist for city and state.  In the code behind, I was able to reference these controls by name, such as ddlstate.  However, I'm creating a new site from the ground up in .net 4.0 and was trying to edit the website that visual web developer 2010 creates when you create a new web site.  I went to the register.aspx page and added the city and state dropdowns.  In the code behind, I can't reference them as ddlstate anymore.  I even tried setting the clientidmode to static at the page level since I know the control names get mangled but that didn't help either.  However, the project builds fine as long as I don't attempt to reference the dropdownlist by name in the code behind. 

I'm also using jquery that I pulled from a working .net 3.5 site I had that gets errors when trying to reference the dropdownlist by name in .net 4.0.  The error says "ddlstate" is not a member of "asp.account_register_aspx".  The dropdownlist is set to runat server so I'm really confused why both my jquery and code behind can't seem to see the control in the createuserwizard control.  If I move the dropdownlist outside of the createuserwizard, it can see it and use it just fine.  A

View Complete Post

More Related Resource Links

How can I make controls inside a Template visible to Code-behind


I have created a custom control that implements Templates (based on Panel controls) ... I can do a FindControl to locate imbedded controls.  This allows me to get and set values in the imbedded controls, but I want to be able to reference the imbedded controls like they are properties of the associated panel.  Here is a sample of how my custom control now works:

<cc:CustomControl ID="myCustomControl" runat="server">
<asp:TextBox ID="myTextBox" runat="server"></asp:TextBox>

I can do the following (where my custom control has given the panel hosting the template the name "myPanel"):

Dim txt As TextBox = myCustomControl.myPanel.FindControl("myTextBox")
txt.Text = "Some text to put in TextBox"

What I want to do is:

myCustomControl.myPanel.myTextBox.Text = "Some text to put in TextBox"

The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>)


Hey guys

I came across this bug using while trying to implement a sitemap

Line 147:						Panel panel = new Panel();
Line 148:						panel.Controls.Add(_viewState);
Line 149:						Page.Form.Controls.Add(panel);
Line 150:						string script = "document.getElementById('" + _viewState.ClientID + "').value = GetViewState__AspNetTreeView('" + Extender.MakeChildId("UL") + "');";
Line 151:						Page.ClientScript.RegisterOnSubmitStatement(typeof(TreeViewAdapter), _viewState.ClientID, script);

[HttpException (0x80004005): The Controls collection cannot be modified because the control contains code blocks (i.e. <% ... %>).]
   System.Web.UI.ControlCollection.Add(Control child) +8696951
   CSSFriendly.TreeViewAdapter.SaveAdapterViewState() in E:\wwwroot\ThirdParty\CSSFriendly\CSSFriendly_24242\CSSFriendly\TreeViewAdapter.cs:149
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +8901848
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148
   System.Web.UI.Control.SaveViewStateRecursive(ViewStateMode inheritedMode) +148

Toolbox: Microsoft Chart Controls, Visual Studio Automatic Code Snippets, And More


In this installment we look at the Microsoft Chart Controls; Snippet Designer, a free, add-in for Visual Studio 2008 for creating and editing Code Snippets; refactoring SQL applications; and this month's favorite blog.

Scott Mitchell

MSDN Magazine April 2009

Wicked Code: Craft Custom Controls for Silverlight 2


If you're unfamiliar with Windows Presentation Foundation (WPF), building that first Silverlight custom control can be a daunting experience. This article walks through the process.

Jeff Prosise

MSDN Magazine August 2008

Repeater issue, all code inside Repeater are not shown


I have a Repeater who should show some data from my ms.sql server. But all code inside the Repater is not shown on my .aspx page. What am i doing wrong. I have a similar Repeater on another page and there it works fine.


 <div class="AnsaettelseKontrakt Folders">
      	            <table cellpadding="0" cellspacing="0" width="750px" align="right">
                            <th class="BrugerHeader" style="width:300px;">Filnavn</th>
                            <th class="BrugerHeader" style="width:80px;">Størrelse</th>
                            <th class="BrugerHeader" style="width:150px;">Dato</th>
                            <th class="BrugerHeader" style="width:180px;" colspan="2">Brugere</th>
                            <th class="BrugerHeader" style="width:40px;">Værktøjer</th>
                        <asp:Repeater ID="RepeaterAns" runat="server" onitemcommand="Repeater1_ItemCommand" >
                                <tr class="Br

Custom controls and ViewState management issue



I want to know that when we create custom controls, then is there State Management through ViewState done automatically or we have to handle it explicitely ?Since i have created Custom Controls that is behaving as if it is not maintaining its state on PostBack.

Problem with list controls and update progress template



I have an update panel that surrounds a wizard control which I use in conjunction with a update progress control. Now my update progress control works perfectly, with my animated gif and div tag that lays over my wizard control when the user goes from step to step. However, there is a problem that I am struggling to solve. A number of my steps use controls like list boxes, and when the update progress control fires, the list control is not laying underneath my div an animated gif no matter how high a make my css z-index on the div.

Does anyone have a way of solving this?


In a style template, express a property in terms of the controls properties it is applied to.

Hello,   In the style template below, which works fine, I'd like to express the "Points" property in terms of the applied to controls "Width" and "Height" properties.  As you see, the "Fill" property is expressed in terms of the "Background" property the template is applied to by means of Fill="{TemplateBinding Background}".  The following does not work:   Points="0,({TemplateBinding Height} / 4)  ({TemplateBinding Width} / 12.5),({TemplateBinding Height} / 4) . . ."   Is what I'm looking for possible, all in XAML, no code/converters? <Style x:Key="FolderButton" TargetType="Button"> <Setter Property="Margin" Value="2.5" /> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type Button}"> <Grid> <Polygon Fill="{TemplateBinding Background}" Stroke="{TemplateBinding BorderBrush}" Points="0,5 4,5 6,0 23,0 25,5 50,5 50,20 0,20"/> <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/> </Grid> </ControlTemplate>

Get the controls from a TabItem's data template

Hello, I am using the following Style on a custom TabItem that I am using: <Style TargetType="{x:Type local:GSFTabItem}"> <Style.Resources> <cmn:EnumDisplayConverter x:Key="Converter" Type="{x:Type crys:GSFOperator}"/> <local:GSFTabVisibilityConverter x:Key="visibility"/> </Style.Resources> <Setter Property="DataContext" Value="{DynamicResource GSFObject}"></Setter> <Setter Property="Header" Value="{Binding Field}"/> <Setter Property="Content" Value="{DynamicResource GSFObject}"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:GSFTabItem}"> <Grid> <Border Name="Border" BorderBrush="Black" BorderThickness=".5,.5,.5,0" Background="White" > <StackPanel Orientation="Horizontal"> <Label VerticalAlignment="Center" HorizontalAlignment="Center" Content="{Binding Field}"/> <Label Content="X" IsHitTestVisible="True"

SSIS And Sybase Source OLEDB connectivity issue with code page for character set

Hi I am using SSIS 2008 to connect the Sybase Server version 15.0.3 64-bit. The default character set id used by this Sybase server is 4 (i.e. roman8). (http://manuals.sybase.com/onlinebooks/group-charc/chg0300e/charsets/@Generic__BookTextView/1706;pt=266) I had installed Sybase Client for Sybase OLEDB Driver (ASEOLEDB) to integrate this in OLEDB Source Editor. As per guidance from one of the past MSDN forum discussion, I tried setting property of AlwaysUseDefaultCodePage property to "FALSE"  (http://social.msdn.microsoft.com/forums/en-US/sqlintegrationservices/thread/f5af9328-e1fb-48d7-a85d-1d08bb7cf0e5/). However, I am still experiencing error message as follows:- ********************************************************* Error at Package2 [Connection manager "xxxxxx.xxxxxxx"]: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available.  Source: "ASEOLEDB"  Hresult: 0x80004005  Description: "[00000] [Native Code: 30061] [ASEOLEDB]Could not load code page for requested charset". An OLE DB record is available.  Source: "ASEOLEDB"  Hresult: 0x80004005  Description: "[1ZZ001] [Native Code: 30016] [ASEOLEDB]Internal Error". Error at Data Flow Task 2 [OLE DB Source [1]]: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMC

Issue accessing textbox controls nested within a DetailsView within an UpdatePanel

I have a couple of textboxes nested with a detailsview, within an updatepanel.  When I try and access them from the code behind, it returns a null value as if they don't exist.  Can't figure out why that would be.ASPX code is: <asp:UpdatePanel ID="upSpecificShout" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" > <ContentTemplate> <asp:DetailsView ID="dvSingleShout" DataSourceID="sdsSingleShout" runat="server" AutoGenerateRows="false" OnDataBound="SetDVIcons" HeaderStyle-CssClass="noDisplay" > <EmptyDataTemplate> <p class="Watermark"> The panel on the left shows a list of everything you've shouted. (Your replies to other shouts are highlighted in blue/green.) </p> <p class="Watermark"> This right hand panel will show specific shouts with a list of replies etc.. Just do a little click on a shout title to display more detail here. </p> <p class="Watermark">

Issue with Custom Controls

Hi,we are facing a page loading  problem with custom controls only IE browser. but that the same page open on mozilla firefox 3.5.  we are using all the controls on the page are custom controls. I pasted on custom control code bellow, please verify that is it written proper or not...  using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.UI.Design; using System.IO; using System.Configuration; using System.Web.UI.WebControls.WebParts; using System.Drawing.Design; using System.Data; namespace Ays4.Web.UI { #region class CustomizeTextBox [ToolboxData("<{0}:CustomizeTextBox runat=server></{0}:CustomizeTextBox>")] [Designer("System.Web.UI.Design.ReadWriteControlDesigner, System.Design")] [PersistChildren(true)] [ParseChildren(false)] public class CustomizeTextBox : WebControl, INamingContainer { #region Attribute private validateType.ValidationType _ValidationType = validateType.ValidationType.None; private TextBoxType.Mode _Mode = TextBoxType.Mode.None; HtmlTable mainTable; string strJs = ""; private TextBox _inputControl; strin

Rooms and Equipment Reservations Application template using WSS 3.0 issue.

I have set up a conference room reservations site using the RER template, I have questions...The template functions pretty much as I want out of the box, except for two items.1.)  Any User can delete any other user's reservation.2.)  Any User can delete a resource.Does anyone know of a way to resolve these issues?  All users need contribute permissions to use the site.

Save as Site Template issue with Enable Labels Policy

I am having issues saving a site as a template. I have a basic team site. The only thing i have done is set 'Enable Labels' on the Shared Document library, the label format being {version} I then try to save site as a template and get the error... Error Error exporting the list named "Shared Documents" at the URL: Shared Documents Any ideas? I have replicated this issue on a new build of SharePoint 2010 in a test environment.

dropdownlist controls in gridview issue

 the below code creates drop down each time i add a category to the database table. however, i don't wish to have drop down created each time - how can i have all my data in one drop down? thanks...  <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CascadingDropDownTestConnectionString %>"  SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Category]">  </asp:SqlDataSource>    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CategoryID"  DataSourceID="SqlDataSource1">  <Columns>  <asp:BoundField DataField="CategoryID" HeaderText="CategoryID" InsertVisible="False"  ReadOnly="True" SortExpression="CategoryID" />  <asp:TemplateField HeaderText="Categories">  <ItemTemplate>  <asp:DropDownList ID="ddlCategories" AutoPostBack="true" DataTextField="CategoryName"  DataValueField="CategoryID" DataSourceID="SqlDataSource1" runat="server" AppendDataBoundItems="true"  SelectedValue='<%# Bind("CategoryID") %>' />  &

Code from the ground up, or use just populate placed controls?


As an Ex ASP Classic moving to ASP.net (VB) i find the following situation, and i'm looking for some direction in terms of best practice.  

As i'm sure we all do when we start, i easily get lost in all the controls and clever wizard driven development features.  however, my best .net work so far has been without any drag/dropped controls, but rather programatically creating whatever controls/connections/dataobjects i need, populating, acting on and disposing of thereafter.

There was a post i saw (somewhere) which referred to the sqldatasource and gridview controls and their consorts as "training wheels" controls and i identified with that statement straight away.

Now here's the question: is this a question of arbitrary "preference" or is this something that has larger implications later on?   I realize that it's a kind of up-in-the-air question, but I don't want to be more specific than that in my question because I want to see what others think about this.

Need some help with the AnimationExtender controls in C# code behind only


Hi all,

I'm developing a custom webpart for MS Project 2007 (sharepoint 2007 engine). I would like to have exactly the same result as this demonstration -> http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/Animation/Animation.aspx but the window is displaying above my button and not correctly. I need your help, please.

Here is my code:

Literal div1 = new Literal();

            div1.Text = "";
            div1.Text += "<div id='flyout' style='display: none; overflow: hidden; z-index: 2; background-color: #FFFFFF; border: solid 1px #D0D0D0;'></div>";

            div1.Text += "<div id='info' style='display: block; width: 250px; z-index: 2; opacity: 0; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0); font-size: 12px; border: solid 1px #CCCCCC; background-color: #FFFFFF; padding: 5px;'>";
            div1.Text += "    <div id='btnCloseParent' style='float: right; opacity: 0; filter: progid:DXImageTransform.Microsoft.Alpha(opacity=0);'>X";
            div1.Text += "        <a onclick='return false;' id='btnClose' title='Close' href='#' style='background-color: #FF5B00; color: #000000; text-align: center; font-weight: bold; text-decoration: non
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