.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

finding control id and setting properties in other pages

Posted By:      Posted Date: October 23, 2010    Points: 0   Category :ASP.Net

hi can anybody help me how to code,

im using a webusercontrol (hide.ascx) it has 2 buttons btn_hide,btn_expand

and in my other forms of all like(products.aspx)customers.aspx,orders.aspx

im using a panel conrol(pnl_products) where in im placing all the input controls.

i want to find the panel control in hide.ascx page and to set that

panel.visble=true/false property in this page.

so that expand and collapse the panel in each page.

View Complete Post

More Related Resource Links

Advanced Basics: Setting Word Document Properties the Office 2007 Way


The last time I wrote this column (March 2006), I shared an application that allows you to update all the Microsoft® Word documents in a folder and its subfolders. Each time the application finds a document in the specified path, it updates the document properties to match those you specified in the application.

Ken Getz

MSDN Magazine June 2006

Finding a control from a control collection



I'm trying to write a bit of code that will format all the numeric values in lables in my gridview. here's what i am doing right now:

On the RowDataBound Event, i create a row object for the row that is currently being bound.
then i go use the FindControl method to grab each label by name.

Problem is there's too many columns in this table and i really dont wnat to have to type it all out. Here's an example of what i am currently doing

' Get row being bound
Dim myRow = e.Row

' Get labes to be formatted
Dim lblMunicipalIncineration = CType(myRow.FindControl("lblMunicipalIncineration"), Label)

' format labels
If lblMunicipalIncineration IsNot Nothing Then
    If Not String.IsNullOrEmpty(lblMunicipalIncineration.Text) Then
        lblMunicipalIncineration.Text = FormatNumber(lblMunicipalIncineration.Text, 0, TriState.False, TriState.False, TriState.True)
    End If
End If

Can i use myRow.Controls to grab a list of all the controls and then somehow get a list of all labels in the collection and then use a for loop to go through and format each label?

User Control not accessing the value of the properties send to it from the aspx page.


I have a dynamic accordion on a page. Set its datasource to an object of paged data source.The user control is in the accordions content template. When i was writing code the properties were showing but after giving the values of databases as


<uc:UserControl1  runat="server" Property1='<%#DataBinder.Eval(Container.DataItem,"columname1")%>' Property2='<%#DataBinder.Eval(Container.DataItem,"columname2")%>'  ></uc:UserControl1>


but the values shows null, these properties are shown as textboxes text property by user control.

MoreOver when I checked the values of database Items.So i made a textbox instead of usercontrol here as

<asp:TextBox ID="txtTest" runat="server" Text='<%#DataBinder.Eval(Container.DataItem,"Columname1")%>'></asp:TextBox>

It is showing the correct value. And if i pass the value directly it is also showing correctly like

<uc:UserControl1  runat="server" Property1="XYZ")%>' Property2="ABC")%>'  ></uc:UserControl1>

. where I am wrong

the problem is eval is not passing the value to usercont

Problem with User Control Properties


I've been trying to figure out a problem that I've had for the past week and believe that the issue is something with a user control that I created. In short, the properties for the user control are recognized by intelisense when I register the control and then add it in the markup for a page. However, the values that I set in the markup are ignored by the class as if the properties don't exist.



Parent Page

 <%@ Register Src="../../controls/contactdetail.ascx" TagName="ContactDetail" TagPrefix="tfc" %>

<tfc:ContactDetail runat="server" ID="UserControlContactDetail" Title="Contact-Detail" ContactId="1580" EnableViewState="true" />   



User Control Class

Imports System.Data
Imports System.Data.SqlClient

Partial Class control_ContactDetail
    Inherits System.Web.UI.UserControl
    Public Property ContactId() As Integer
            Return _ContactId
        End Get
        Set(ByVal value As Integer)
            _ContactId = value
        End Set
    End Property
    Private _ContactId As Integer
    Public Property Title() As String
            Return _Title
        End Get

problem on Page_PreRender with RangeValidator control and programmatically setting Maximum and Minim

I am new to the ASP.NET /C# dev. I run into a weird bug when using the RangeValidator Control inside a Formview. I have my DateTime field with validator and it work fine until I submit the page, it actually insert the row into the database but then when the page reload I get the following exception.Server Error in '/Budget' Application. The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [HttpException (0x80004005): The value '' of the MaximumValue property of 'RV_AjoutUtilisateurDate' cannot be converted to type 'Date'.] System.Web.UI.WebControls.RangeValidator.ValidateValues() +1077011 System.Web.UI.WebControls.RangeValidator.ControlPropertiesValid() +12

Finding a WPF control by Name in a Panel

How can I loop through the controls collection of a WPF panel and find a control by name?  The StackPanel1.Children(0).Name property does not exist. I looking for a method equivelent to this WinForm code... Friend Function DBX_FindControlByName(ByRef objContainer As Object, _   ByVal strControlName As String, _   ByRef objFoundControl As Control) As Boolean   Dim objControl As Control = Nothing   If Not IsNothing(objFoundControl) Then Return True   Try   'objContainer must be a controls collection like Me.Controls   For Each objControl In CType(objContainer, Control.ControlCollection)   If objControl.Name.ToUpper = strControlName.ToUpper Then objFoundControl = objControl   Exit For   Else   If objControl.HasChildren Then   'This control has children so it must be a container DBX_FindControlByName(objControl.Controls, strControlName, objFoundControl)   End If   End If   Next   Return True   Catch ex As Exception strErrMsg = "DBX_FindControlByName." & objControl.Name & ": " & ex.Message   End Try   End Function Thanks. Mike

Finding broken links in a web of Pages

I have a dozen sub-sites all with large Pages libraries of .aspx pages created and maintained under the Publishing features on  MOSS 2007.  Some links also go to Document libraries. How do I detect broken links within the web of .aspx pages? 

Creating a volume control slider/setting one template property based on another

So, what I want to do, is to make a volume control that looks like a right angle triangle with the 90 degree angle on the bottom right, and then when you click on it, the area to the left of the selected point is shown in a different color.  In other words, I've created a slider with the right background, what I can't do, is work out how to show the selected area by filling in the triangle.  I have worked out how to bind the height of my triangle on the left to the value of the control, but right now, the rate of rise is exactly half of what I need it to be.  I need to know how to change the template for the area to the left of the selection ( which is the repeat button ) so that the background is twice the height that it is right now.  No matter what size I make the slider, the area is always 1/2 the size it needs to be, so I am sure if I could get it to double inside my template, it would work fine. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">       <Style x:Key="SliderButtonStyle" TargetType="{x:Type RepeatButton}">         <Setter Property="SnapsToDevicePixels" Value="true"/>         <

How to Bind a child control with properties of the parent control in Silverlight and WPF?

Dear Experts, I have a usercontrol in Silverlight and I want to enable the update button inside the usercontrol with property defined in the usercontrol. For the proof of concept sake I have defined the usercontrol xaml and the code behind in VB.NETBelow is the XAML and VB.NET Code. ----------------------------------------------------------------------- <UserControl x:Class="SLBAppAssementQuestions.SilverlightControl1"     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"     xmlns:d="http://schemas.microsoft.com/expression/blend/2008"     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"     mc:Ignorable="d"     d:DesignHeight="300" d:DesignWidth="400">     <StackPanel>         <CheckBox x:Name="chkBox1" Margin="10" Checked="chkBox1_Checked" >Checkbox1</CheckBox>         <CheckBox x:Name="chkBox2" Margin="10" Checked="chkBox2_Checked">Checkbox1</CheckBox>         <Button  x:Name="BtnUpdate&q

How to control the text and other properties in ResourceDictionary object that i wrote ?

I wrote some ResourceDictionary. This ResourceDictionary is actuly a button that i use - I created this button by using Rectangle and TextBlock ==> that mean that the my xaml look like the code below. The problem is that i cant change the font size and the text of the TextBlock. I can change is just from the xaml of the template. And ... How can i define some variable that will control on the rectAngle redius in runtime ? Someone can help ?? ? Thanks. ...<ResourceDictionary> <Style x:Key="MyBtn" TargetType="{x:Type Button}"> <Rectangle ... <TextBlock.... </ResourceDictionary> ...

User control or sub-form inside tab-pages? Best practice?

I've got a Windows Forms application with numerous tab-pages within a tab-control. Each tab-page is a diffirent user entry form with different controls of varying types. As the application is fairly large it is important that more than one developer can work on it simultaneously. Thus we decided to create a form for each tab so that different developers could work on different forms at the same time without overwriting each other's code. Each of these "sub-forms" are then assigned its relevant container tab-page as its parent. This works well but I was wondering if this is good practice or not, after another colleague commented that we are making forms look like user controls and that we should rather be creating a user control for each tab. I've converted two of the forms to user controls with relative ease and it does work nicely as well but with one draw back. On the main parent form, e.g. frmMain, where the tab control lives, there is one single button the clear the current display. When you click "Clear display" it clears various others items displayed on the main from, finds the current selected tab and clears its contents. The latter is easy to do with sub forms as I can simply close and dispose the sub form inside the selected tab, and load a new instance. I don't have to write custom logic to go and reset/clear each control on that form. Thi

error provider control in aspx pages?

how can i add error provider control in an asp.net page using c#..  for example,if i am using a textbox control which prompts the user to fill it on clicking the submit button,how should i make the textbox control to prompt the user. someone help me with this!!! and also reply me if v can use status strip control in aspx pages

Insert and Edit Pages with Web User Control Template for another table

Hi, I have an Address template(web user control) which holds the fields of the Address table.  The Address template is embedded in the School Insert Page.  I want to insert a new school together with its address(which means I have to insert a record into the address table).  Can you let me know how I can pass the newly generated addressId to update school table?  Also, how can I associate the Address.cs in the App_Code with the Address template?  I want it to be able to scaffold columns which needs to be hidden from user in the address table.  When I click on Insert School, the Address template shows in "insert" mode, I just need to link the two together. Thanks for your help! CC  

LoginView.FindControl not finding control

I'm trying to bind data to a repeater. The repeater is inside a loginView control. Like so:            <asp:loginview id="loginView" runat="server">                <anonymoustemplate>                    <asp:repeater id="rpLessons" runat="server">                                            <itemtemplate>                            <div>                                <a  href="Default.aspx?lid=<%# Eval("PodID") %>"><%# Eval("Name") %></a><%#Eval("Duration")%>                            </div>                        </itemtemplate>    &n

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

Problem setting variable/param in XSLT for XML control in .NET 4.0

I am using an XML control in VS2010 with .NET 4.0.I am trying to sort XML data into a table. I have a drop list with the sort key, and a button that is supposed to display the table with a new sort.Here is the code the button calls:</p><p></p><p style="text-align: left;" mce_style="text-align: left;"><font class="Apple-style-span" face="Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace"><span class="Apple-style-span" style="border-collapse: collapse; line-height: 13px;" mce_style="border-collapse: collapse; line-height: 13px;" mce_fixed="1"></span></font></p><p><font class="Apple-style-span" face="Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace"></font></p><p><font class="Apple-style-span" face="Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace"><div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">private void PopulateXML( Xml MyXML)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: h

Problem binding business objects to custom user control properties

I have created a user control (supplierPicker) intended to allows a supplier database to be searched and a supplier selected. I want to be able to use this control in a number of other user controls, by binding the suppplierID property of the supplierPicker to a supplierID property in a business object, which is set as the datacontext of the parent user control. When I do this, and there is a supplierID specified in the business ofbject, the binding sets the supplierID in the supplierPicker control and it shows the correct supplier name in the textbox. However when the supplierID DependencyProperty is changed from within the supplierPicker the newly selected supplier name is shown in the TextBox, but the SupplierID does not propogate back to the business object. Other controls on the parent form work fine, so the binding to the business object seems to be ok. Any pointers as to what I'm doing wrong here would be grately appreciated.  This one has been driving me nuts for days! Snipped code for the supplier picker:         public partial class SupplierPicker : UserControl, INotifyPropertyChanged     {         public static DependencyProperty SupplierIDProperty;         public event PropertyChangedEventHandler PropertyChan
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