Search Results

Search found 6151 results on 247 pages for 'controls'.

Page 8/247 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Programatically loading user controls

    - by PhilSando
    Today's little problem is that I am trying to load user controls from my codebehind like so: Dim myControl As UserControl = Page.LoadControl("~\Modules\Content.ascx")              Controls.Add(myControl)  On running the page myControl is no where to be seen. I wonder why that is? Well after a bit of thought the following come to mind... Am I using the correct code to insert the usercontrol? Is there an alternative available? Does the fact that the usercontrol has a page_load method make a difference? Does the fact that the usercontrol is being called from the page_init method make a difference? Do I need to register the control in my aspx page at design time? I'll be looking to answer these questions as the day goes on!

    Read the article

  • Event Handlers and Automatic Postback in ASP.NET 3.5 Web Controls

    In one of last week s tutorials Creating Database-Driven ASP.NET 3.5 Input and List Web Controls you learned how to create a dynamic input web control that instead of setting values statically stored its list and values directly from the MS SQL server 2 8 database. This tutorial is a sequel to that article. It deals mostly with the server side coding aspect of dynamic web controls. It is recommended that you read the earlier tutorial first as the Visual Web Developer Project in that tutorial will be used extensively in this article.... Download a Free Trial of Windows 7 Reduce Management Costs and Improve Productivity with Windows 7

    Read the article

  • Tooltip Support For ASP.NET Image Controls v2010 vol 1

    Tooltip property has been added to DevExpress ASP.NET image controls! Starting with DXperience v2010.1, all DevExpress ASP.NET image controls like the ASPxImage have a new property called: Tooltip. Whats a tooltip? Wikipedia defines it as: The tooltip is a common graphical user interface element. It is used in conjunction with a cursor, usually a mouse pointer. The user hovers the cursor over an item, without clicking it, and a tooltip may appear a small "hover box" with information...Did you know that DotNetSlackers also publishes .net articles written by top known .net Authors? We already have over 80 articles in several categories including Silverlight. Take a look: here.

    Read the article

  • Custom widgets/controls in application indicators

    - by markitusss
    I want to develop an app for ubuntu, that integrates inside the calendar indicator/menu. It should allow to enter info right from it, and have several controls like input boxes, drop downs, spinners and buttons. Is this possible to integrate/replace the standard date/time indicator? If not, is it possible to create it as a separate indicator that when clicked opens a popup with all the controls and stuff? I want it to look as part of the sys tray and not as a separate desktop app. I'm using Quickly for this. Thanks for your help!

    Read the article

  • Visual Studio 2013, ASP.NET MVC 5 Scaffolded Controls, and Bootstrap

    - by plitwin
    A few days ago, I created an ASP.NET MVC 5 project in the brand new Visual Studio 2013. I added some model classes and then proceeded to scaffold a controller class and views using the Entity Framework. Scaffolding Some Views Visual Studio 2013, by default, uses the Bootstrap 3 responsive CSS framework. Great; after all, we all want our web sites to be responsive and work well on mobile devices. Here’s an example of a scaffolded Create view as shown in Google Chrome browser   Looks pretty good. Okay, so let’s increase the width of the Title, Description, Address, and Date/Time textboxes. And decrease the width of the  State and MaxActors textbox controls. Can’t be that hard… Digging Into the Code Let’s take a look at the scaffolded Create.cshtml file. Here’s a snippet of code behind the Create view. Pretty simple stuff. @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> <h4>RandomAct</h4> <hr /> @Html.ValidationSummary(true) <div class="form-group"> @Html.LabelFor(model => model.Title, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Title) @Html.ValidationMessageFor(model => model.Title) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.Description, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.EditorFor(model => model.Description) @Html.ValidationMessageFor(model => model.Description) </div> </div> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } A little more digging and I discover that there are three CSS files of importance in how the page is rendered: boostrap.css (and its minimized cohort) and site.css as shown below.   The Root of the Problem And here’s the root of the problem which you’ll find the following CSS in Site.css: /* Set width on the form input elements since they're 100% wide by default */ input, select, textarea { max-width: 280px; } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Yes, Microsoft is for some reason setting the maximum width of all input, select, and textarea controls to 280 pixels. Not sure the motivation behind this, but until you change this or overrride this by assigning the form controls to some other CSS class, your controls will never be able to be wider than 280px. The Fix Okay, so here’s the deal: I hope to become very competent in all things Bootstrap in the near future, but I don’t think you should have to become a Bootstrap guru in order to modify some scaffolded control widths. And you don’t. Here is the solution I came up with: Find the aforementioned CSS code in SIte.css and change it to something more tenable. Such as: /* Set width on the form input elements since they're 100% wide by default */ input, select, textarea { max-width: 600px; } Because the @Html.EditorFor html helper doesn’t support the passing of HTML attributes, you will need to repalce any @Html.EditorFor() helpers with @Html.TextboxFor(), @Html.TextAreaFor, @Html.CheckBoxFor, etc. helpers, and then add a custom width attribute to each control you wish to modify. Thus, the earlier stretch of code might end up looking like this: @using (Html.BeginForm()) { @Html.AntiForgeryToken() <div class="form-horizontal"> <h4>Random Act</h4> <hr /> @Html.ValidationSummary(true) <div class="form-group"> @Html.LabelFor(model => model.Title, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.TextBoxFor(model => model.Title, new { style = "width: 400px" }) @Html.ValidationMessageFor(model => model.Title) </div> </div> <div class="form-group"> @Html.LabelFor(model => model.Description, new { @class = "control-label col-md-2" }) <div class="col-md-10"> @Html.TextAreaFor(model => model.Description, new { style = "width: 400px" }) @Html.ValidationMessageFor(model => model.Description) </div> </div> .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } Resulting Form Here’s what the page looks like after the fix: Technorati Tags: ASP.NET MVC,ASP.NET MVC 5,Bootstrap

    Read the article

  • When to draw/layout child controls in UserControl

    - by Ted Elliott
    I have a list-type UserControl (like a ListBox). The items inside the control are another complex UserControl containing a few other controls (ComboBox, TextBox, etc). I'm wondering what the preferred or best method would be to override to draw/layout the child controls. I basically want to trigger this method any time the list changes. I originally had a RedrawItems method that I just called whenever I needed to redraw which added or removed Controls from the Controls collection. But it was getting triggered too early in the lifecycle of the code from some of the designer code. Now I've switched to overriding OnLayout and doing my stuff there. I call PerformLayout when I want to trigger a redraw, such as when the DataSource property changes or when it fires a changed event. Is OnLayout the best place for this? Here is the code: [ComplexBindingProperties("DataSource")] public partial class CustomList : UserControl { private object _dataSource; private CustomListItem _newRow; public CustomList() { InitializeComponent(); } protected override void OnCreateControl() { base.OnCreateControl(); _newRow = new CustomListItem(); Controls.Add(_newRow); } public object DataSource { get { return _dataSource; } set { bool register = _dataSource != value; if (_dataSource != null && _dataSource != value) { UnregisterDataSource(_dataSource); } _dataSource = value; if (_dataSource != null) RegisterDataSource(_dataSource); PerformLayout(); } } public CustomListItem ItemTemplate { get { return _newRow; } } protected override void OnLayout(LayoutEventArgs e) { base.OnLayout(e); int ctrlCount = this.Controls.AsEnumerable().OfType<CustomListItem>().Count(); ctrlCount--; // subtract 1 for the add row var ds = this.DataSource as System.Collections.IList; int itemCount = ds == null? 0 : ds.Count; int maxCount = Math.Max(ctrlCount,itemCount); if (maxCount == 0) return; this.SuspendLayout(); // temporarily remove the template Controls.RemoveAt(Controls.Count-1); for (int i = 0; i < maxCount; i++) { CustomListItem item; if (i >= itemCount) { Controls.RemoveAt(i); } else { if (i >= ctrlCount) { item = ItemTemplate.Copy(); this.Controls.Add(item); item.Location = new Point(0, item.Height * i); item.TabIndex = i + 1; item.ViewMode = true; } else { item = (CustomListItem) Controls[i]; } item.Data = ds[i]; } } this.Controls.Add(ItemTemplate); ItemTemplate.Location = new Point(0, ItemTemplate.Height * maxCount); ItemTemplate.TabIndex = maxCount + 1; this.ResumeLayout(true); } private void RegisterDataSource(object dataSource) { IBindingList ds = dataSource as IBindingList; if (ds != null) { ds.ListChanged += new ListChangedEventHandler(DataSource_ListChanged); } } void DataSource_ListChanged(object sender, ListChangedEventArgs e) { switch (e.ListChangedType) { case ListChangedType.ItemAdded: PerformLayout(); break; case ListChangedType.ItemChanged: break; case ListChangedType.ItemDeleted: PerformLayout(); break; case ListChangedType.ItemMoved: PerformLayout(); break; case ListChangedType.Reset: PerformLayout(); break; default: break; } } private void UnregisterDataSource(object dataSource) { IBindingList ds = dataSource as IBindingList; if (ds != null) { ds.ListChanged -= new ListChangedEventHandler(DataSource_ListChanged); } } }

    Read the article

  • [ASP.NET 4.0] Persisting Row Selection in Data Controls

    - by HosamKamel
    Data Control Selection Feature In ASP.NET 2.0: ASP.NET Data Controls row selection feature was based on row index (in the current page), this of course produce an issue if you try to select an item in the first page then navigate to the second page without select any record you will find the same row (with the same index) selected in the second page! In the sample application attached: Select the second row in the books GridView. Navigate to second page without doing any selection You will find the second row in the second page selected. Persisting Row Selection: Is a new feature which replace the old selection mechanism which based on row index to be based on the row data key instead. This means that if you select the third row on page 1 and move to page 2, nothing is selected on page 2. When you move back to page 1, the third row is still selected. Data Control Selection Feature In ASP.NET 3.5 SP1: The Persisting Row Selection was initially supported only in Dynamic Data projects Data Control Selection Feature In ASP.NET 4.0: Persisted selection is now supported for the GridView and ListView controls in all projects. You can enable this feature by setting the EnablePersistedSelection property, as shown below: Important thing to note, once you enable this feature you have to set the DataKeyNames property too because as discussed the full approach is based on the Row Data Key Simple feature but  is a much more natural behavior than the behavior in earlier versions of ASP.NET. Download Demo Project

    Read the article

  • Ubuntu 12.04 - Brightness controls not working

    - by Juan Manuel Zolezzi Volpi
    Controls from "Brightness and Lock" were not working so I've tried a solution that involved changing grub, which I'm detailing below: # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' GRUB_DEFAULT=0 #GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX="quiet splash acpi_backlight=vendor" # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480 # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_RECOVERY="true" # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1" After doing this, the brightness control dissapeared like you can see at http://screencloud.net/img/screenshots/6b90d56604b70cc749a632d0bc005a20.png Any ideas? Would love to be able to configure Brightness or even use apps like F.lux to regulate it automatically. Edit: I've modified the following line to GRUB_CMDLINE_LINUX_DEFAULT="quiet splash acpi_osi=" and now the brightness controls are back, but whatever I change the brightness remains the same. Just in case I'm using Intel H77

    Read the article

  • Send Multiple InMemory Attachments Using FileUpload Controls

    - by bullpit
    I wanted to give users an ability to send multiple attachments from the web application. I did not want anything fancy, just a few FileUpload controls on the page and then send the email. So I dropped five FileUpload controls on the web page and created a function to send email with multiple attachments. Here’s the code: public static void SendMail(string fromAddress, string toAddress, string subject, string body, HttpFileCollection fileCollection)     {         // CREATE THE MailMessage OBJECT         MailMessage mail = new MailMessage();           // SET ADDRESSES         mail.From = new MailAddress(fromAddress);         mail.To.Add(toAddress);           // SET CONTENT         mail.Subject = subject;         mail.Body = body;         mail.IsBodyHtml = false;                        // ATTACH FILES FROM HttpFileCollection         for (int i = 0; i < fileCollection.Count; i++)         {             HttpPostedFile file = fileCollection[i];             if (file.ContentLength > 0)             {                 Attachment attachment = new Attachment(file.InputStream, Path.GetFileName(file.FileName));                 mail.Attachments.Add(attachment);             }         }           // SEND MESSAGE         SmtpClient smtp = new SmtpClient("127.0.0.1");         smtp.Send(mail);     } And here’s how you call the method: protected void uxSendMail_Click(object sender, EventArgs e)     {         HttpFileCollection fileCollection = Request.Files;         string fromAddress = "[email protected]";         string toAddress = "[email protected]";         string subject = "Multiple Mail Attachment Test";         string body = "Mail Attachments Included";         HelperClass.SendMail(fromAddress, toAddress, subject, body, fileCollection);            }

    Read the article

  • Chrome window controls in xubuntu 12.04

    - by Norbert
    I'm a long time ubuntu 10.04 LTS user, very used to having window controls on top left borders. New computer with new video card requires newer kernel. Unity doesn't suit and much googling turned up recommendations for xubuntu. Installed 12.04 and first aggravation is window controls at upper right a la Windows. No problem ... Settings Manager - Windows Manager - rearrange button layout Fixes everything until ... I abandoned firefox long ago because of memory leak issues and general fat. I fetch a current version of chrome (19.0.1084.52) and install. Once adblock is added and it's the default browser, everything's great. Except ... Alone among all applications, chrome will not honour the window manager's preferred button layout. Buttons are at upper right no matter what I try. Uninstall and then reinstall: nope. Trawl through /home/user/.config/google-chrome/* looking for a likely setting: nope. Search the web: nothing useful. How do I get chrome's window decoration in sync? Thanks very much for any and all help.

    Read the article

  • Windows Phone 7 : Dragging and flicking UI controls

    - by TechTwaddle
    Who would want to flick and drag UI controls!? There might not be many use cases but I think some concepts here are worthy of a post. So we will create a simple silverlight application for windows phone 7, containing a canvas element on which we’ll place a button control and an image and then, as the title says, drag and flick the controls. Here’s Mainpage.xaml, <Grid x:Name="LayoutRoot" Background="Transparent">   <Grid.RowDefinitions>     <RowDefinition Height="Auto"/>     <RowDefinition Height="*"/>   </Grid.RowDefinitions>     <!--TitlePanel contains the name of the application and page title-->   <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">     <TextBlock x:Name="ApplicationTitle" Text="KINETICS" Style="{StaticResource PhoneTextNormalStyle}"/>     <TextBlock x:Name="PageTitle" Text="drag and flick" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>   </StackPanel>     <!--ContentPanel - place additional content here-->   <Grid x:Name="ContentPanel" Grid.Row="1" >     <Canvas x:Name="MainCanvas" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">       <Canvas.Background>         <LinearGradientBrush StartPoint="0 0" EndPoint="0 1">           <GradientStop Offset="0" Color="Black"/>           <GradientStop Offset="1.5" Color="BlanchedAlmond"/>         </LinearGradientBrush>       </Canvas.Background>     </Canvas>   </Grid> </Grid> the second row in the main grid contains a canvas element, MainCanvas, with its horizontal and vertical alignment set to stretch so that it occupies the entire grid. The canvas background is a linear gradient brush starting with Black and ending with BlanchedAlmond. We’ll add the button and image control to this canvas at run time. Moving to Mainpage.xaml.cs the Mainpage class contains the following members, public partial class MainPage : PhoneApplicationPage {     Button FlickButton;     Image FlickImage;       FrameworkElement ElemToMove = null;     double ElemVelX, ElemVelY;       const double SPEED_FACTOR = 60;       DispatcherTimer timer; FlickButton and FlickImage are the controls that we’ll add to the canvas. ElemToMove, ElemVelX and ElemVelY will be used by the timer callback to move the ui control. SPEED_FACTOR is used to scale the velocities of ui controls. Here’s the Mainpage constructor, // Constructor public MainPage() {     InitializeComponent();       AddButtonToCanvas();       AddImageToCanvas();       timer = new DispatcherTimer();     timer.Interval = TimeSpan.FromMilliseconds(35);     timer.Tick += new EventHandler(OnTimerTick); } We’ll look at those AddButton and AddImage functions in a moment. The constructor initializes a timer which fires every 35 milliseconds, this timer will be started after the flick gesture completes with some inertia. Back to AddButton and AddImage functions, void AddButtonToCanvas() {     LinearGradientBrush brush;     GradientStop stop1, stop2;       Random rand = new Random(DateTime.Now.Millisecond);       FlickButton = new Button();     FlickButton.Content = "";     FlickButton.Width = 100;     FlickButton.Height = 100;       brush = new LinearGradientBrush();     brush.StartPoint = new Point(0, 0);     brush.EndPoint = new Point(0, 1);       stop1 = new GradientStop();     stop1.Offset = 0;     stop1.Color = Colors.White;       stop2 = new GradientStop();     stop2.Offset = 1;     stop2.Color = (Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush).Color;       brush.GradientStops.Add(stop1);     brush.GradientStops.Add(stop2);       FlickButton.Background = brush;       Canvas.SetTop(FlickButton, rand.Next(0, 400));     Canvas.SetLeft(FlickButton, rand.Next(0, 200));       MainCanvas.Children.Add(FlickButton);       //subscribe to events     FlickButton.ManipulationDelta += new EventHandler<ManipulationDeltaEventArgs>(OnManipulationDelta);     FlickButton.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(OnManipulationCompleted); } this function is basically glorifying a simple task. After creating the button and setting its height and width, its background is set to a linear gradient brush. The direction of the gradient is from top towards bottom and notice that the second stop color is the PhoneAccentColor, which changes along with the theme of the device. The line,     stop2.Color = (Application.Current.Resources["PhoneAccentBrush"] as SolidColorBrush).Color; does the magic of extracting the PhoneAccentBrush from application’s resources, getting its color and assigning it to the gradient stop. AddImage function is straight forward in comparison, void AddImageToCanvas() {     Random rand = new Random(DateTime.Now.Millisecond);       FlickImage = new Image();     FlickImage.Source = new BitmapImage(new Uri("/images/Marble.png", UriKind.Relative));       Canvas.SetTop(FlickImage, rand.Next(0, 400));     Canvas.SetLeft(FlickImage, rand.Next(0, 200));       MainCanvas.Children.Add(FlickImage);       //subscribe to events     FlickImage.ManipulationDelta += new EventHandler<ManipulationDeltaEventArgs>(OnManipulationDelta);     FlickImage.ManipulationCompleted += new EventHandler<ManipulationCompletedEventArgs>(OnManipulationCompleted); } The ManipulationDelta and ManipulationCompleted handlers are same for both the button and the image. OnManipulationDelta() should look familiar, a similar implementation was used in the previous post, void OnManipulationDelta(object sender, ManipulationDeltaEventArgs args) {     FrameworkElement Elem = sender as FrameworkElement;       double Left = Canvas.GetLeft(Elem);     double Top = Canvas.GetTop(Elem);       Left += args.DeltaManipulation.Translation.X;     Top += args.DeltaManipulation.Translation.Y;       //check for bounds     if (Left < 0)     {         Left = 0;     }     else if (Left > (MainCanvas.ActualWidth - Elem.ActualWidth))     {         Left = MainCanvas.ActualWidth - Elem.ActualWidth;     }       if (Top < 0)     {         Top = 0;     }     else if (Top > (MainCanvas.ActualHeight - Elem.ActualHeight))     {         Top = MainCanvas.ActualHeight - Elem.ActualHeight;     }       Canvas.SetLeft(Elem, Left);     Canvas.SetTop(Elem, Top); } all it does is calculate the control’s position, check for bounds and then set the top and left of the control. OnManipulationCompleted() is more interesting because here we need to check if the gesture completed with any inertia and if it did, start the timer and continue to move the ui control until it comes to a halt slowly, void OnManipulationCompleted(object sender, ManipulationCompletedEventArgs args) {     FrameworkElement Elem = sender as FrameworkElement;       if (args.IsInertial)     {         ElemToMove = Elem;           Debug.WriteLine("Linear VelX:{0:0.00}  VelY:{1:0.00}", args.FinalVelocities.LinearVelocity.X,             args.FinalVelocities.LinearVelocity.Y);           ElemVelX = args.FinalVelocities.LinearVelocity.X / SPEED_FACTOR;         ElemVelY = args.FinalVelocities.LinearVelocity.Y / SPEED_FACTOR;           timer.Start();     } } ManipulationCompletedEventArgs contains a member, IsInertial, which is set to true if the manipulation was completed with some inertia. args.FinalVelocities.LinearVelocity.X and .Y will contain the velocities along the X and Y axis. We need to scale down these values so they can be used to increment the ui control’s position sensibly. A reference to the ui control is stored in ElemToMove and the velocities are stored as well, these will be used in the timer callback to access the ui control. And finally, we start the timer. The timer callback function is as follows, void OnTimerTick(object sender, EventArgs e) {     if (null != ElemToMove)     {         double Left, Top;         Left = Canvas.GetLeft(ElemToMove);         Top = Canvas.GetTop(ElemToMove);           Left += ElemVelX;         Top += ElemVelY;           //check for bounds         if (Left < 0)         {             Left = 0;             ElemVelX *= -1;         }         else if (Left > (MainCanvas.ActualWidth - ElemToMove.ActualWidth))         {             Left = MainCanvas.ActualWidth - ElemToMove.ActualWidth;             ElemVelX *= -1;         }           if (Top < 0)         {             Top = 0;             ElemVelY *= -1;         }         else if (Top > (MainCanvas.ActualHeight - ElemToMove.ActualHeight))         {             Top = MainCanvas.ActualHeight - ElemToMove.ActualHeight;             ElemVelY *= -1;         }           Canvas.SetLeft(ElemToMove, Left);         Canvas.SetTop(ElemToMove, Top);           //reduce x,y velocities gradually         ElemVelX *= 0.9;         ElemVelY *= 0.9;           //when velocities become too low, break         if (Math.Abs(ElemVelX) < 1.0 && Math.Abs(ElemVelY) < 1.0)         {             timer.Stop();             ElemToMove = null;         }     } } if ElemToMove is not null, we get the top and left values of the control and increment the values with their X and Y velocities. Check for bounds, and if the control goes out of bounds we reverse its velocity. Towards the end, the velocities are reduced by 10% every time the timer callback is called, and if the velocities reach too low values the timer is stopped and ElemToMove is made null. Here’s a short video of the program, the video is a little dodgy because my display driver refuses to run the animations smoothly. The flicks aren’t always recognised but the program should run well on an actual device (or a pc with better configuration), You can download the source code from here: ButtonDragAndFlick.zip

    Read the article

  • Child web.config can't clear <pages><controls> from parent web.config

    - by Lance Rushing
    How can I "clear" the vendor defined <controls> in my child app's web.config? Parent Web Config. <system.web> <pages> <controls> <!-- START: Vendor Custom Control --> <add tagPrefix="asp" namespace="VENDOR.Web.UI.Base" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral /> ... <!-- END: Vendor Custom Control --> ... </controls> <tagMapping> <add tagType="System.Web.UI.WebControls.WebParts.WebPartManager" mappedTagType="Microsoft.Web.Preview.UI.Controls.WebParts.WebPartManager" /> <add tagType="System.Web.UI.WebControls.WebParts.WebPartZone" mappedTagType="Microsoft.Web.Preview.UI.Controls.WebParts.WebPartZone" /> </tagMapping> </pages> </system.web> Child: <system.web> <pages> <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/> </controls> <tagMapping> <clear/> </tagMapping> </pages> </system.web> I have it working for the <tagMapping> section, but <controls> does not support <clear/> (or ).

    Read the article

  • Controls.remove() method not working in asp.net

    - by user279521
    I have a web app where the user can create dynamic textboxes at run time. When the user clicks SUBMIT, the form sends data to the database and I want remove the dynamic controls. The controls are created in the following code: Table tb = new Table(); tb.ID = "tbl"; for (i = 0; i < myCount; i += 1) { TableRow tr = new TableRow(); TextBox txtEmplName = new TextBox(); TextBox txtEmplEmail = new TextBox(); TextBox txtEmplPhone = new TextBox(); TextBox txtEmplPosition = new TextBox(); TextBox txtEmplOfficeID = new TextBox(); txtEmplName.ID = "txtEmplName" + i.ToString(); txtEmplEmail.ID = "txtEmplEmail" + i.ToString(); txtEmplPhone.ID = "txtEmplPhone" + i.ToString(); txtEmplPosition.ID = "txtEmplPosition" + i.ToString(); txtEmplOfficeID.ID = "txtEmplOfficeID" + i.ToString(); tr.Cells.Add(tc); tb.Rows.Add(tr); } Panel1.Controls.Add(tb); The Remove section of the code is: Table t = (Table)Page.FindControl("Panel1").FindControl("tbl"); foreach (TableRow tr in t.Rows) { for (i = 1; i < myCount; i += 1) { string txtEmplName = "txtEmplName" + i; tr.Controls.Remove(t.FindControl(txtEmplName)); string txtEmplEmail = "txtEmplEmail" + i; tr.Controls.Remove(t.FindControl(txtEmplEmail)); string txtEmplPhone = "txtEmplPhone" + i; tr.Controls.Remove(t.FindControl(txtEmplPhone)); string txtEmplPosition = "txtEmplPosition" + i; tr.Controls.Remove(t.FindControl(txtEmplPosition)); string txtEmplOfficeID = "txtEmplOfficeID" + i; tr.Controls.Remove(t.FindControl(txtEmplOfficeID)); } } However, the textboxes are still visible. Any ideas?

    Read the article

  • WPF User Control is causing Out of Memory Exception

    - by Chairman Meow
    Looking for a free spell checking solution, I thought I was so smart in doing this but I guess not. I have created a windows form based application and I want the form to add a user specified amount of user controls (with textboxes) on to a panel. The user can then click some button and the controls on this panel are cleared and new ones are added. The user does something and the process is repeated. Now, I wanted these textboxes to support spell checking and looked all over for a free solution. WPF textboxes support spell checking where the ones in regular win forms do not. I thought I would be able to use these WPF textboxes by adding them to an ElementHost object which is, in turn, within a panel. This panel would be a user control. So, in my application, I would be able to add instances of these user controls onto the form and make use of .NET's spell checking goodness. This actually worked but after using the application for a while, found that the application would eventually freeze on me due to out of memory errors. I have pinpointed the memory errors to these WPF controls since this problem does not happen with normal textboxes. When the window is opened and the number of controls is specified, this is pretty much how the controls are added: Dim xOffset As Integer = 0 For i As Integer = 0 To theNumber Dim myUserControl As New SpecialUserControl() myPanel.Controls.Add(myUserControl) myUserControl.Location = New Point(7, 7) myUserControl.Location = New Point(xOffset, 7) xOffset = xOffset + 207 Next Note that: myPanel is a panel on a form SpecialUserControl is the user control with WPF textbox (within an ElementHost object) When the user pressed a button, the panel is cleared: myUserControl.Controls.Clear() The user can then repeat the process. There are a lot of results on the internet when I tried to find a solution and I'm thinking that the problem I am having is due to the fact that the WPF control is not going away even after clearing the panel. Following this conclusion, I have tried different solutions regarding disposing these controls or setting them to nothing but the memory problem keeps occurring. If someone could give me some advice or ideas here, I'd really appreciate it.

    Read the article

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