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

Tuesday, 27 October 2015

Paging datatable using linq

dt.AsEnumerable().Skip(10).Take(10)





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

Tuesday, 22 September 2015

Devexpress: datasource binded ASPxComboBox fail to set selected on page load

                <dx:ASPxComboBox  ValueField="Id" TextField="Ethinicity" DataSourceID="ethincitydatasource"  SelectedIndex="0" runat="server" ID="cmbEthinicity" Width="250px" Height="32px" CssClass="textbox-style-account" ValueType="System.Int32">
                                    <DropDownButton>
                                        <Image Url="images/down.png"></Image>
                                    </DropDownButton>
                                    <ValidationSettings ValidationGroup="SaveCompanyInfo" Display="Static" ErrorDisplayMode="Text" ErrorTextPosition="Bottom" EnableCustomValidation="True" CausesValidation="True">
                                        <RequiredField IsRequired="True" ErrorText="Select Ethinicity" />
                                    </ValidationSettings>
                                </dx:ASPxComboBox>
                                <data: EthinicityMasterDataSource runat="server" ID="ethincitydatasource" SelectMethod="GetAll"></data: EthinicityMasterDataSource>

Code on cs

protected void Page_Load(object sender, EventArgs e)
    {if (!IsPostBack)
            {
                     cmbEthinicity.DataBind();
                     cmbEthinicity.Value = Convert.ToInt32(objPpiClient.EthinicityId);
}
}

Key solution: cmbEthinicity.DataBind();

bind again before setting selected index.
                         



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

Tuesday, 8 September 2015

Windows 10 Critical Error - Start menu and Cortana aren't working. Resolved

Restart pressing f8

 




Avast logo

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


Thursday, 27 August 2015

Telephone Number Masking in Devexpress

     <dx:ASPxTextBox CssClass="devxminiinput" Width="300px" runat="server" ID="txtMobileNumber" ClientInstanceName="txtMobileNumber" NullText="Mobile Number">
                            <MaskSettings Mask="(00)-0000000000" IncludeLiterals="DecimalSymbol" ErrorText="Invalid" />
                    <ClientSideEvents Validation="function(s,e)  { if (e.value == null || e.value =='') e.isValid = true; }" />
                        </dx:ASPxTextBox>





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

Thursday, 23 July 2015

pass tabular data at client side / array

Server Side:
        var publicationTable = new List{};
       // reportpricingservice.GetAll().ForEach(a=> publicationTable.Add(new object[]{a.ReportTypeId,a.TestTypeId,a.Price}));
        reportpricingservice.GetAll().ForEach(a => publicationTable.Add(new {a.ReportTypeId, a.TestTypeId, a.Price }));
        return (new JavaScriptSerializer()).Serialize(publicationTable);

Client side:
var reportpricings = <%= getReportPricing() %>;

 function getprice(TestType,ReportType)
        {
            return $.grep(reportpricings, function (reportpricing)
            {
                return (reportpricing.ReportTypeId == ReportType && reportpricing.TestTypeId == TestType);
            })[0].Price;
        }


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

Friday, 17 July 2015

codesmith datasource sort and filter

<data:XXXMasterDataSource runat="server" ID="XXXrDataSource1" SelectMethod="GetPaged">

                <Parameters>

                    <data:CustomParameter Name="WhereClause" Value="IsProfile=1" ConvertEmptyStringToNull="false" />

                    <data:CustomParameter Name="OrderBy" Value="ReportType" ConvertEmptyStringToNull="false" />

                </Parameters>

            </data:XXXMasterDataSource>




Avast logo

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


Thursday, 30 April 2015

Call Outlook From Winform

  Microsoft.Office.Interop.Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();

            Microsoft.Office.Interop.Outlook.MailItem mailItem = (Microsoft.Office.Interop.Outlook.MailItem)outlookApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);

            mailItem.Subject = "This is the subject";

            mailItem.To = "someone@example.com";

            mailItem.Body = "This is the message.";

            mailItem.Importance = Microsoft.Office.Interop.Outlook.OlImportance.olImportanceLow;

            mailItem.Display(false);

       

 

Thursday, 9 April 2015

NopCommerce how to add password strength in Registration page


1) In nopCommerce code, the register page is in this location:
RootFolder\Views\Customer\ Register.cshtml   <-- Open this file
2) Locate this in your code:
<div class="form-fields">
                    <div class="inputs">
                        @Html.LabelFor(model => model.Password, new { }, ":")
                        @Html.EditorFor(model => model.Password)
                        @Html.RequiredHint()
                        @Html.ValidationMessageFor(model => model.Password)
                    </div>
                    <div class="inputs">
                        @Html.LabelFor(model => model.ConfirmPassword, new { }, ":")
                        @Html.EditorFor(model => model.ConfirmPassword)
                        @Html.RequiredHint()
                        @Html.ValidationMessageFor(model => model.ConfirmPassword)
                    </div>
                    @if (Model.DisplayCaptcha)
                    {
                        <div class="captcha-box">
                            @Html.Raw(Html.GenerateCaptcha())
                        </div>
                    }
                </div>
3) In this case, we need to add javascript, jquery and css in order to target our password  field. So, in order to do that we will add this in our "Register.cshtml" page:
<script type='text/javascript'>
    $(function () {
        // This applies the Strength checking plug-in to your particular element
        $('#Password').strength({ strengthButtonText:"" });
        // Fixup your Required indicator (inserts it explicitly after your password element)
        $('.required-indicator').insertAfter($("#Password"));
    });
</script>
Note: Here the JQuery $('#Password') will reference the password input field.
4) We also need to add respective JQuery like this:
<!-- Example jQuery -->
<script type="text/javascript"src="http://www.StrivingProgrammers.com/ScriptFiles_Extras/js/jquery.min.js"></script>
<!-- Strength.js -->
<script type="text/javascript"src="http://www.StrivingProgrammers.com/ScriptFiles_Extras/js/strength.js"></script>
Note: "strength.js" is the file where it is defined what is a weak, medium and strong password. You can change it according to your requirements if you want.
5) Now, we will add our CSS styling to it like this:
<style type='text/css'>
    .strength_meter, .strength_meter * {
        display: inline;
    }
</style>

Monday, 6 April 2015

NopCommerce - Folder Permission

nopCommerce requires write permissions for the directories and files described below:

<![if !supportLists]>·         <![endif]>\App_Data\
<![if !supportLists]>·         <![endif]>\bin\
<![if !supportLists]>·         <![endif]>\Content\
<![if !supportLists]>·         <![endif]>\Content\Images\
<![if !supportLists]>·         <![endif]>\Content\Images\Thumbs\
<![if !supportLists]>·         <![endif]>\Content\Images\Uploaded\
<![if !supportLists]>·         <![endif]>\Content\files\ExportImport\
<![if !supportLists]>·         <![endif]>\Plugins\
<![if !supportLists]>·         <![endif]>\Plugins\bin\
<![if !supportLists]>·         <![endif]>\Global.asax
<![if !supportLists]>·         <![endif]>\web.config




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

Friday, 3 April 2015

Update Table w.r.t. another table Key

UPDATE table2
SET table2.col1 = table1.col1,
table2.col2 = table1.col2,
...
FROM table1, table2
WHERE table1.memberid = table2.memberid




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

Wednesday, 1 April 2015

How To Deploy Nop-Commerce

How to Deploy Nop Commerce  (To be Edited)

1.             Build the project.

2.             Publish Nop.Web to the ~\Deploy directory.

3.             Change database connection at ~\Deploy\Presentation\Nop.Web\App_Data\Settings.txt

4.             Copy all files from ~\Presentation\Nop.Web\Plugins to ~\Deploy\Plugins

5.             Copy images from ~\Presentation\Nop.Web\Content\Images to ~\Deploy\Content\Images

6.             Copy ~\Presentation\Nop.Web\App_Data\InstalledPlugins.txt to ~\Deploy\Nop.Web\App_Data\InstalledPlugins.txt to 

 




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