Search Results

Search found 918 results on 37 pages for 'usercontrol'.

Page 10/37 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Add UserControl To Page From Another Class

    - by Raika
    I have page and call method inside my page. I want to add some control to my page Control (not page itself) inside that method. namespace Program { public partail class Default : Page { protected void Page_Load(object sender, Eventargs e) { MyClass.Calling(this); } } } in another class namespace Program { public class MyClass { public static void Calling(Page page) { Textbox txt = new Textbox() // I want somthing like this. // page.PlaceHolder1.Controls.Add(txt); } } } Is this possible? My Default.aspx : <%@ Page Title="Home Page" MasterPageFile="~/Site.master" ... %> <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> </asp:Content> Update: thanks to The King for help. his suggest work correctly if control is inside page not Content of master page like my defualt sample code.

    Read the article

  • How to expose a control collection to a property grid at design time

    - by Stefano Delendati
    I have a custom control that with a property that is a collection of custom object. This custom object hava a reference to some component/controls. When at design time I tray to add an item to the collection and select the object, VS tells me that the control is not serializable. This is the code (simplified version - but not to much): public class ViewRefObj { public control view { get; set; } public ViewRefObj() { } } private List<ViewRefObj> _controls=new List<ViewRefObj>(); public List<ViewRefObj> Views { get { return _controls; } }

    Read the article

  • Issue with Usercontrol and Border Style

    - by Ram
    Hi, I have created a user control ( custom data grid view control). I have used the code specified at MSDN [site][1] [1]: http://support.microsoft.com/kb/316574 to set the border style . I am able to see the selected border style in designer. Like None, FixedSingle or Fixed3D. But when I set the border style to FixedSingle, the border does not appear at runtime. Do I need to draw it manually in the OnPaint method?

    Read the article

  • Simple user control for conditionally rendering nested HTML

    - by Goyuix
    What I would like to do, is be able to pass two attributes to a user control, a ListName and a Permission, like so: <uc:check id="uc" List="Shared Documents" Permission="OpenItems" runat="server"> <!-- have some HTML content here that is rendered if the permission is true --> </uc:check> Then in the actual check user control, have something similar to: <%@ Control language="C#" ClassName="check" %> <% // determine permission magic placeholder if (DoesUserHavePermissions(perm)) { // render nested HTML content } else { // abort rendering as to not show nested HTML content } %> I have read the page on creating a templated control on MSDN, and while that would work - it really seems to be a bit overkill for what I am trying to do. Is there a control that already renders content based on a boolean expression or a simpler template example? http://msdn.microsoft.com/en-us/library/36574bf6.aspx

    Read the article

  • How to make a particular information to be accessible at masterpage, page and usercontrol

    - by Ismail S
    I'm fetching some settings out of the database based on a value passed from a query string. Out of these settings, a few will be used in master page, few on my Page and few in my user control (say login control which is a web user control). I've an entity class MySetting for it and there is a method in my data access layer which returns me an instance of MySetting when I pass the value I got in query string. I don't want to fetch settings from the database multiple times for one request. I'm using asp.net web forms with C# and sql server.

    Read the article

  • Rails: Best practice to store user settings?

    - by ole_berlin
    Hi, I'm wondering what the best way is to store user settings? For a web 2.0 app I want users to be able to select certain settings. At the moment is it only when to receive email notifications. The easiest way would be to just create a Model "Settings" and have a column for every setting and then have a 1-1 relationship with users. But is there a pattern to solve this better? Is it maybe better to store the info in the user table itself? Or should I use a table with "settings_name" and "settings_value" to be completely open about the type of settings stored there (without having to run any migrations when adding options)? What is your opinion? Thanks

    Read the article

  • MVVM User control - where do i declare it to get data from page ?

    - by Anish
    I have a WPF user control ...which is in MVVM. The user control(which contains a listview) need data from the page (where it is included). I have to set a property in View's code behind to get this data input. Will this comply with MVVM(But MVVM pattern do not support adding code in code behind file of view as far as i know).if not, what is the way for the same?

    Read the article

  • Programatically add UserControl with events

    - by schaermu
    Hi everybody I need to add multiple user controls to a panel for further editing of the contained data. My user control contains some panels, dropdown lists and input elements, which are populated in the user control's Page_Load event. protected void Page_Load(object sender, EventArgs e) { // populate comparer ddl from enum string[] enumNames = Enum.GetNames(typeof (SearchComparision)); var al = new ArrayList(); for (int i = 0; i < enumNames.Length; i++) al.Add(new {Value = i, Name = enumNames[i]}); scOperatorSelection.DataValueField = "Value"; scOperatorSelection.DataTextField = "Name"; ... The data to be displayed is added to the user control as a Field, defined above Page_Load. The signature of the events is the following: public delegate void ControlStateChanged(object sender, SearchCriteriaEventArgs eventArgs); public event ControlStateChanged ItemUpdated; public event ControlStateChanged ItemRemoved; public event ControlStateChanged ItemAdded; The update button on the user control triggers the following method: protected void UpdateCriteria(object sender, EventArgs e) { var searchCritCtl = (SearchCriteria) sender; var scEArgs = new SearchCriteriaEventArgs { TargetCriteria = searchCritCtl.CurrentCriteria.CriteriaId, SearchComparision = ParseCurrentComparer(searchCritCtl.scOperatorSelection.SelectedValue), SearchField = searchCritCtl.scFieldSelection.SelectedValue, SearchValue = searchCritCtl.scFilterValue.Text, ClickTarget = SearchCriteriaClickTarget.Update }; if (ItemUpdated != null) ItemUpdated(this, scEArgs); } The rendering page fetches the data objects from a storage backend and displays it in it's Page_Load event. This is the point where it starts getting tricky: i connect to the custom events! int idIt = 0; foreach (var item in _currentSearch.Items) { SearchCriteria sc = (SearchCriteria)LoadControl("~/content/controls/SearchCriteria.ascx"); sc.ID = "scDispCtl_" + idIt; sc.ControlMode = SearchCriteriaMode.Display; sc.CurrentCriteria = item; sc.ItemUpdated += CriteriaUpdated; sc.ItemRemoved += CriteriaRemoved; pnlDisplayCrit.Controls.Add(sc); idIt++; } When first rendering the page, everything is displayed fine, i get all my data. When i trigger an update event, the user control event is fired correctly, but all fields and controls of the user control are NULL. After a bit of research, i had to come to the conclusion that the event is fired before the controls are initialized... Is there any way to prevent such behavior / to override the page lifecycle somehow? I cannot initialize the user controls in the page's Init-event, because i have to access the Session-Store (not initialized in Page_Init). Any advice is welcome... EDIT: Since we hold all criteria informations in the storage backend (including the count of criteria) and that store uses the userid from the session, we cannot use Page_Init... just for clarification EDIT #2: I managed to get past some of the problems. Since i'm now using simple types, im able to bind all the data declaratively (using a repeater with a simple ItemTemplate). It is bound to the control, they are rendered in correct fashion. On Postback, all the data is rebound to the user control, data is available in the OnDataBinding and OnLoad events, everything looks fine. But as soon it enters the real event (bound to the button control of the user control), all field values are lost somehow... Does anybody know, how the page lifecycle continues to process the request after Databinding/Loading ? I'm going crazy about this issue...

    Read the article

  • ASP.NET DropDownList control doesn't postback correctly inside of UserControl

    - by RichardAZ
    I have a situation where a DropDownList control is not posting back correctly. The AutoPost property is set to true, so the postback does happen, but the SelectedValue is not set to the correct value. In addition, the onSelectedIndexChanged event doesn't fire. The exact same code works perfect fine on an ASPX page, but does not work in a ASCX control. I have tried all the obvious things, I hope, trying to figure this one out, but no luck so far. I have even investigated what comes back in Request.Form["__EVENTTARGET"] and __EVENTARGUMENT. __EVENTTARGET does point to the drop down list, but the argument is empty. Can the folks of StackOverflow help lead me in the right direction to debug this issue. Of course, it is further complicated by master pages and the usual overcomplication of ASP.NET. Here is the code: <div> <asp:DropDownList ID="testDrop" runat="server" AutoPostBack="true" EnableViewState="true" onselectedindexchanged="testDrop_SelectedIndexChanged"> <asp:ListItem Value="1" Text="1">1</asp:ListItem> <asp:ListItem Value="2" Text="2">2</asp:ListItem> </asp:DropDownList> </div> And here is the generated html: <select id="ctl00_MainContent_rptAccordion_ctl00_statControl_testDrop" onchange="javascript:setTimeout('__doPostBack(\'ctl00$MainContent$rptAccordion$ctl00$statControl$testDrop\',\'\')', 0)" name="ctl00$MainContent$rptAccordion$ctl00$statControl$testDrop"> <option value="1" selected="selected">1</option> <option value="2">2</option> THANKS!

    Read the article

  • C# stop property change at runtime

    - by petebob796
    I have been trying to build a user control with some custom properties set in the designer. However the control involves some interop code and settings which shouldn't be adjusted at runtime. Is there a way to stop the values being changed after they have been initially set by the designer code?

    Read the article

  • ASP.NET UserControl Uri property

    - by Roedel
    I want to pass a property of the type System.Uri to an WebControl from inside an aspx page. Is it possible to pass the property like that: <MyUserControl id="myusercontrol" runat="server"> <MyUrlProperty> <System.Uri>http://myurl.com/</System.Uri> </MyUrlProperty> </MyUserControl> instead of: <MyUserControl id="myusercontrol" runat="server" MyUrlProperty="http://myurl.com/" /> which can't be casted from System.String to System.Uri

    Read the article

  • Usercontrol and Border Style

    - by Ram
    Hi, I have created a user control ( custom data grid view control). I have used the code specified at MSDN [site][1] [1]: http://support.microsoft.com/kb/316574 to set the border style . I am able to see the selected border style in designer. Like None, FixedSingle or Fixed3D. But when I set the border style to FixedSingle, the border does not appear at runtime. Do I need to draw it manually in the OnPaint method?

    Read the article

  • UserControlArray in Specific ButtonControlArray in C#

    - by Phanindar
    I am new to C#.I have been thinking of adding a ButtonControlArray where i can store each button control.Here is part of my code.I am creating a 6*6 array of button Control. ButtonControl buttonControl; ButtonControl[,] arrayButtons = new ButtonControl[6,6]; public void createGrid() { l = 0; for (int i = 0; i < numberOfButtons; i++) { for (int k = 0; k < numberOfButtons; k++) { buttonControl = new ButtonControl(); buttonControl.Location = new Point(l,j); j += 55; arrayButtons[i, k] = buttonControl; //After the above statement if i print Console.WriteLine(""+arrayButtons[i,k]); i am getting only my projectname.buttoncontrol myGridControl.Controls.Add(buttonControl); } l += 55; j = 10; } } I want to access each variable in arrayButtons[][]..like in a 3*3 matrix..if i want 2nd row 1 column element..then i get something like arrayname[2][1]..same way if i want 2nd button in 2nd row how can i get..i tried doing one way but i couldnt figure it out...Can you help me out with this..

    Read the article

  • WPF MVVM UserControl Binding "Container", dispose to avoid memory leak.

    - by user178657
    For simplicity. I have a window, with a bindable usercontrol <UserControl Content="{Binding Path = BindingControl, UpdateSourceTrigger=PropertyChanged}"> I have two user controls, ControlA, and ControlB, Both UserControls have their own Datacontext ViewModel, ControlAViewModel and ControlBViewModel. Both ControlAViewModel and ControlBViewModel inh. from a "ViewModelBase" public abstract class ViewModelBase : DependencyObject, INotifyPropertyChanged, IDisposable........ Main window was added to IoC... To set the property of the Bindable UC, i do ComponentRepository.Resolve<MainViewWindow>().Bindingcontrol= new ControlA; ControlA, in its Datacontext, creates a DispatcherTimer, to do "somestuff".. Later on., I need to navigate elsewhere, so the other usercontrol is loaded into the container ComponentRepository.Resolve<MainViewWindow>().Bindingcontrol= new ControlB If i put a break point in the "someStuff" that was in ControlA's datacontext. The DispatcherTimer is still running... i.e. loading a new usercontrol into the bindable Usercontrol on mainwindow does not dispose/close/GC the DispatcherTimer that was created in the DataContext View Model... Ive looked around, and as stated by others, dispose doesnt get called because its not supposed to... :) Not all my usercontrols have DispatcherTimer, just a few that need to do some sort of "read and refresh" updates./. Should i track these DispatcherTimer objects in the ViewModelBase that all Usercontrols inh. and manually stop/dispose them everytime a new usercontrol is loaded? Is there a better way?

    Read the article

  • Can I write a .NETCF Partial Class to extend System.Windows.Forms.UserControl?

    - by eidylon
    Okay... I'm writing a .NET CF (VBNET 2008 3.5 SP1) application, which has one master form, and it dynamically loads specific UserControls based on menu click, in a sort of framework idea. There are certain methods and properties these controls all need to work within the app. Right now I am doing this as an Interface, but this is aggravating as all get up, because some of the methods are optional, and yet I MUST implement them by the nature of interfaces. I would prefer to use inheritance, so that I can have certain code be inherited with overridability, but if I write a class which inherits System.Windows.Forms.UserControl and then inherit my control from that, it squiggles, and tells me that UserControls MUST inherit directly from System.Windows.Forms.UserControl. (Talk about a design flaw!) So next I thought, well, let me use a partial class to extend System.Windows.Forms.UserControl, but when I do that, even though it all seems to compile fine, none of my new properties/methods show up on my controls. Is there any way I can use partial classes to 'extend' System.Windows.Forms.UserControl? For example, can anyone give me a code sample of a partial class which simply adds a MyCount As Integer readonly property to the System.Windows.Forms.UserControl class? If I can just see how to get this going, I can take it from there and add the rest of my functionality. Thanks in advance! I've been searching google, but can't find anything that seems to work for UserControl extension on .NET CF. And the Interface method is driving me crazy as even a small change means updating ALL the controls whether they need to 'override' the method or not.

    Read the article

  • How to simulate postback in nested usercontrols?

    - by jaloplo
    Hi all, I'm doing an asp.net application with one page. In this page, I have one usercontrol defined. This usercontrol has a menu (three buttons) and 3 usercontrols defined too. Depending on the clicked button one of the three usercontrols turn to visible true or false. In these three usercontrols I have a button and a message, and I want to show the message "It's NOT postback" when the button of the menu is clicked, and when the button of the usercontrol is clicked the message will be "YES, it's postback!!!". The question is that using property "IsPostBack" of the usercontrol or the page the message will never be "It's NOT postback" because of the clicked button of the menu to show the nested usercontrol. This is the structure of the page: page parent usercontrol menu nested usercontrol 1 message button nested usercontrol 2 nested usercontrol 3 I know it can be done using ViewState but, there is a way to simulate IsPostBack property or know when is the true usercontrol postback? Thanks.

    Read the article

  • OnDataBinding firing before OnLoad of a CustomGridViewControl in a UserControl?

    - by OutOFTouch
    Hi, I have a CustomGridViewControl that is on a UserControl, the UserControl is loaded outside of the Page_Init when a treeview in the page is clicked that changes the view, than on subsequent postbacks the UserControl is loaded in Page_Init. The custom gridview is bound to a dataview that is dynamically retrieved. Problem is that the OnDataBinding of the CustomGridView is firing before the OnLoad of the CustomGridView, which is causing me to not be able to get embedded resource urls. Any suggestions? Thanks!

    Read the article

  • Set property on usercontrol that can be used in custom panel in control... Silverlight

    - by Dimestore Cowboy
    I have a simple usercontrol that uses a simple custom panel where I just overrode the Orientation and Measure functions. What I want to do is to have a property in the usercontol to control the orientation So I basicaly have UserControl -- Listbox -- MyPanel And I want a property for the usercontrol that can be set in xaml (of type System.Windows.Controls.Orientation ) that I can bind to from my custom panel (or a different approach if binding isnt the right way to do it) It would be a bonus if that property could show up in the properties window and you could select vertical or horizontal. And a super bonus if I could change the property at design time and have the listbox/

    Read the article

  • How can I get to the value of my WPF UserControl DependencyProperty from UI Automation Framework?

    - by Surfbutler
    Hi, I'm having trouble getting access to my WPF UserControl DependencyProperty values through the UI Automation Framework. I've used James McCaffreys article in MSDN as a starting point (Automating IO Tests in WPF Applications, MSDN March 2009), but I can only see properties etc in standard controls such as buttons. I'm assuming there's some Automation interface I have to implement on my UserControl, but what and how? I can already see my control fine e.g. in UISpy, but I can't see the dependency properties within it. Here's what my usercontrol looks like currently in UISpy: AutomationElement General Accessibility AccessKey: "" AcceleratorKey: "" IsKeyboardFocusable: "False" LabeledBy: "(null)" HelpText: "Switches 48v Phantom Power On/Off (for Mic inputs only)." State IsEnabled: "True" HasKeyboardFocus: "False" Identification ClassName: "" ControlType: "ControlType.Custom" Culture: "(null)" AutomationId: "V48SwL" LocalizedControlType: "custom" Name: "" ProcessId: "5684 (VirtualSix)" RuntimeId: "7 5684 40026340" IsPassword: "False" IsControlElement: "True" IsContentElement: "True" Visibility BoundingRectangle: "(140, 457, 31, 20)" ClickablePoint: "155,467" IsOffscreen: "False" ControlPatterns

    Read the article

  • In an asp.net, how to get a reference of a custom webcontrol from a usercontrol?

    - by AJ
    Hi I have a page which holds a custom webcontrol and a usercontrol. I need to reference of webcontrol in usercontrol class. So, I make the declaration of webcontrol as public in page class. But, when I do “this.Page.”, I don’t see the webcontrol listed in list provided by intellisense. Most probably, I am missing something. In an asp.net page, how to get a reference of a custom webcontrol from a usercontrol? Please advise. Thanks Pankaj

    Read the article

  • Databinding to ObservableCollection in a different UserControl - how to preserve current selections?

    - by Dave
    Scope of question expanded on 2010-03-25 I ended up figuring out my problem, but here's a new problem that came up as a result of solving the original question, because I want to be able to award the bounty to someone!!! Once I figured out my problem, I soon found out that when the ObservableCollection updates, the databound ComboBox has its contents repopulated, but most of the selections have been blanked out. I assume that in this case, MVVM is going to make it difficult for me to remember the last selected item. I have an idea, but it seems a little nasty. I'll award the bounty to whomever comes up with a nice solution for this! Question re-written on 2010-03-24 I have two UserControls, where one is a dialog that has a TabControl, and the other is one that appears within said TabControl. I'll just call them CandyDialog and CandyNameViewer for simplicity's sake. There's also a data management class called Tracker that manages information storage, which for all intents and purposes just exposes a public property that is an ObservableCollection. I display the CandyNameViewer in CandyDialog via code behind, like this: private void CandyDialog_Loaded( object sender, RoutedEventArgs e) { _candyviewer = new CandyViewer(); _candyviewer.DataContext = _tracker; candy_tab.Content = _candyviewer; } The CandyViewer's XAML looks like this (edited for kaxaml): <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Page.Resources> <DataTemplate x:Key="CandyItemTemplate"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="120"></ColumnDefinition> <ColumnDefinition Width="150"></ColumnDefinition> </Grid.ColumnDefinitions> <TextBox Grid.Column="0" Text="{Binding CandyName}" Margin="3"></TextBox> <!-- just binding to DataContext ends up using InventoryItem as parent, so we need to get to the UserControl --> <ComboBox Grid.Column="1" SelectedItem="{Binding SelectedCandy, Mode=TwoWay}" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=DataContext.CandyNames}" Margin="3"></ComboBox> </Grid> </DataTemplate> </Page.Resources> <Grid> <ListBox DockPanel.Dock="Top" ItemsSource="{Binding CandyBoxContents, Mode=TwoWay}" ItemTemplate="{StaticResource CandyItemTemplate}" /> </Grid> </Page> Now everything works fine when the controls are loaded. As long as CandyNames is populated first, and then the consumer UserControl is displayed, all of the names are there. I obviously don't get any errors in the Output Window or anything like that. The issue I have is that when the ObservableCollection is modified from the model, those changes are not reflected in the consumer UserControl! I've never had this problem before; all of my previous uses of ObservableCollection updated fine, although in those cases I wasn't databinding across assemblies. Although I am currently only adding and removing candy names to/from the ObservableCollection, at a later date I will likely also allow renaming from the model side. Is there something I did wrong? Is there a good way to actually debug this? Reed Copsey indicates here that inter-UserControl databinding is possible. Unfortunately, my favorite Bea Stollnitz article on WPF databinding debugging doesn't suggest anything that I could use for this particular problem.

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >