Monday, 23 November 2015

Response.Redirect cannot be called in a Page callback

Issue:Response.Redirect cannot be called in a Page callback when using devexpress controls

Solution :
  if (Session.IsNewSession || !User.Identity.IsAuthenticated)
            if (IsCallback)
                DevExpress.Web.ASPxClasses.ASPxWebControl.RedirectOnCallback("SessionTimeout.aspx");
            else
                Response.Redirect("SessionTimeout.aspx");




Avast logo
This email has been checked for viruses by Avast antivirus software.
www.avast.com

Sunday, 15 November 2015

How to Repair a database with Suspect

Please execute the following sql command with replacing “YourDatabase”

EXEC sp_resetstatus [YourDatabase];
ALTER DATABASE [YourDatabase] SET EMERGENCY
DBCC checkdb([YourDatabase])
ALTER DATABASE [YourDatabase] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ([YourDatabase], REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE [YourDatabase] SET MULTI_USER




Avast logo
This email has been checked for viruses by Avast antivirus software.
www.avast.com

Thursday, 12 November 2015

devexpress ASPxMemo set Maxlength

function SetMaxLength(memo, maxLength) {
            if (!memo)
                return;
            if (typeof (maxLength) != "undefined" && maxLength >= 0) {
                memo.maxLength = maxLength;
                memo.maxLengthTimerToken = window.setInterval(function () {
                    var text = memo.GetText();
                    if (text && text.length > memo.maxLength)
                        memo.SetText(text.substr(0, memo.maxLength));
                }, 10);
            } else if (memo.maxLengthTimerToken) {
                window.clearInterval(memo.maxLengthTimerToken);
                delete memo.maxLengthTimerToken;
                delete memo.maxLength;
            }
        }

<dx:ASPxMemo Height="80px" CssClass="devxLargeinput midwidtn" ID="txtEnterpriseDo" AutoResizeWithContainer="true" CssPostfix="ConnectToGrow" CssFilePath="~/css/devxpresscustom.css" Width="100%" runat="server">
                    <ClientSideEvents Init="function(s,e){SetMaxLength(s, 500)}" />
                </dx:ASPxMemo>





Avast logo
This email has been checked for viruses by Avast antivirus software.
www.avast.com

Sunday, 1 November 2015

Javascript to alert on window web closure

Here is a code to alert the user on window closure or tab closure in web browser.

function setConfirmUnload(on) {
            window.onbeforeunload = (on) ? unloadMessage : null;
        }

        function unloadMessage() {
            return "Are you sure you want to leave this page without saving your details? Please click the save button at the bottom of the page.";
        }

        window.onload = function () {
            setConfirmUnload(true);
        }



Avast logo
This email has been checked for viruses by Avast antivirus software.
www.avast.com