SIGN UP MEMBER LOGIN:    
ARTICLE

Enable and Disable delete button in LightSwitch Application

Posted by Vineet Kumar Saini Articles | VS LightSwitch 2011 November 29, 2011
In this article you learn how to disable and enable a delete button in LightSwitch.
Reader Level:

Introduction

Normally a Delete button is used to remove unwanted information. Whenever we have unwanted data then we use a delete button. In this article you learn how to disable and enable a delete button in LightSwitch.

Step 1: Open Visual Studio LightSwitch->File->New->Project->Create new table.

image1.gif

Step 2: Now we will make a table like student.

image2.gif

Step 3: Go to Properties in solution explorer.

image3.gif

Step 4: Select Use form authentication->Mark Granted for debug.

image4.gif

Step 5: Right click on screen->Add screen.

image5.gif

Step 6: Select Editable grid screen->Select screen data (student)->Ok.

image6.gif

Step 7: Run Application (Press F5)->Click + sign->Fill data->Ok->Save.

image11.gif

Step 8: Now you can delete any student data using the delete button.

image7.gif

Step 9: If you want to disable the delete button then click write code->Student_CanDelete->Now write the below code.

image8.gif

using
System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.LightSwitch;
using Microsoft.LightSwitch.Security.Server;
namespace LightSwitchApplication
{
    public partial class ApplicationDataService
    {
        partial void Students_CanDelete(ref bool result)
        {
            result = this.Application.User.HasPermission(
            Permissions.SecurityAdministration);
        }
    }
}

Step 10: Go to properties in Solution explorer->Use form authentication->Unmark Granted for debug.

image9.gif

Step 11: Run application (Press F5)->Now you can't delete student data because delete button is disabled.

image10.gif

Summary

A Delete button is very useful for remove unwanted data. Whenever we have we have wrong data the we use a delete button. This article is very useful for enable and disable a delete button in LightSwitch Application.

Login to add your contents and source code to this article
share this article :
post comment
 
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor