Sunday, November 3, 2013

Change an Image while using JCrop

Initialize jCrop
var jcrop_api;
        function InitjCrop() {
            $('#id').Jcrop({  }, function () {
                jcrop_api = this;
            });
        }
To unhook jCrop
jcrop_api.destroy();
To Hook jCrop again
InitjCrop();

Wednesday, October 30, 2013

How do I cancel a Delete in MSSQL SERVER

We use instead of delete trigger's ROLLBACK TRAN to cancel a delete statement CREATE TRIGGER dbo.t__protect__locked__from__delete
ON dbo.table
instead OF DELETE
AS
  BEGIN
      SET nocount ON

      DECLARE @IsLocked BIT,
              @ID       INT

      SELECT @IsLocked = IsLocked,@ID = ID
      FROM   deleted

      IF @IsLocked = 1
        BEGIN
            RAISERROR ('Cannot delete',16,1)
            ROLLBACK TRAN
            RETURN
        END
      -- Go ahead and do the update or some other business rules here
      ELSE
        DELETE FROM table
        WHERE  ( ID = @ID )
  END
GO

Tuesday, October 29, 2013

FormView must be in insert mode to insert a new record.

Just change
<asp:LinkButton ...........CommandName="Insert">New</asp:LinkButton>
to
<asp:LinkButton .......... CommandName="New">New</asp:LinkButton>

Monday, October 28, 2013

Validating date using Range Validator asp net

Q: Why Validate date using Range Validator? 
A: All validation controls use culture specified in the web.config globalization tag. We don't need to hard code values every time we change culture. So using Range Validator as a date comparator makes things easy. To use range validator make sure to specify Type="Date" else it won't work. Choose Maximum and Minimum Values as required

<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Invalid Date" 
Type="Date" ControlToValidate="{}" MaximumValue="3000-12-12" MinimumValue="1900-12-12">
</asp:RangeValidator>

Thanks

Crystal Reports: Suppressing a object based on condition

Suppressing a object based on condition is pretty easy. Just use a Boolean field or Boolean parameter or an expression that returns Boolean value.

No if else is required.

e.g.

{?ShowPaid}
 
If it returns true object will be suppressed else no