Sunday, May 21, 2023

Database First Scaffold-DbContext Build failed error

 When you are building entity classes with Scaffold-DbContext sometimes you might encounter the Build failed error.

We can avoid this error by making sure your project does not have compile time errors. That mean the project should build successfully.


Cheers

Samitha


Friday, April 28, 2023

web application exists on both the local IIS web server and the IIS Express web server

When debugging the website in VS 2022   I got this strange issue, Following steps sorted the issue for me.


  • close VS 2022
  • Delete the files in C:\Users\<username>\Documents\IISExpress\config folder
  • Open the solution and tru running it again


Cheers,

Samitha

Sunday, April 9, 2023

Thursday, March 23, 2023

The type 'ASP.global_asax' exists in both DLLs

When trying to compile .Net web project I encountered following error.


"The type 'ASP.global_asax' exists in both 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\timesheet\15a75c54\898b48b9\assembly\dl3\58b062b2\00ceda54_c98cc801\App_global.asax.DLL' and 'c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\timesheet\15a75c54\898b48b9\App_global.asax.q_h6dbfx.dll' c:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\timesheet\15a75c54\898b48b9\App_Web_admin.master.fdf7a39c.zecazgwd.0.cs "


When further troubleshooting in found that problem occurred in a virtual application's bin folder. Inside bin-folder there were two files.


App_global.asax.dll

App_global.asax.compiled


Removing these resolves the error for me.


Cheers

Samitha


Tuesday, March 7, 2023

jquery dialog remove title bar

If we wanted to remove  jquery dialog  title for a specific modal, use create event as show below
 $("#details").dialog({
    modal: true,
    create: function() {
      $(".ui-dialog").find(".ui-dialog-titlebar").css({
        'background-image': 'none',
        'background-color': 'white',
        'border': 'none'
      });
    }
  });

Cheers,
Samitha


Monday, February 20, 2023

SQL RAISERROR pass parameter




    If we want to parameterise SQL  RAISERROR  function  we can easily do that as display below.

 

DECLARE @Msg VARCHAR(100)

SET @Msg = 'Number exceeded on ' +FORMAT (getdate(), 'dd/MM/yyyy')

RAISERROR (@Msg , 16, 1) 


Cheers

Samitha

Friday, February 3, 2023

Telerik Radeditor show remaining character count

We can use jQuery to show remaining character count for a RadEditor as shown below.  This will wok for both design and HTML modes. Here MaxTextLength is considered as the upper character limit,

JS

var textLength;

var maxTextLength;

 function radEditorOnClientLoad(editor, args) {

   maxTextLength = editor.get_maxTextLength();

    textLength = editor.get_text().length;

       if (textLength > maxTextLength)

        $('#charCountSpan' ).html("Characters Remaining: Limit Exceeded ");

    else

        $('#charCountSpan').html("Characters Remaining: " + (maxTextLength - textLength) );

    

    $(editor.get_textArea()).on("input propertychange change keyup", ChangeCharacterCount);

    $(editor.get_contentArea()).on("input propertychange change keyup", ChangeCharacterCount);

}

function ChangeCharacterCount( ) {

var editorElement = $find(<%= txtDetails.ClientID %>);

textLength = editorElement.get_text().length;

                if (textLength > maxTextLength)

                    $('#charCountSpan').html("Characters Remaining: <span class='LimitExceed'>Limit Exceeded </span>");

                else

                   $('#charCountSpan').html("Characters Remaining: " + numberWithCommas(maxTextLength - textLength));

}

HTML

 <telerik:RadEditor ID="txtDetails" runat="server" TextMode="MultiLine"   MaxTextLength ="2000" OnClientLoad="radEditorOnClientLoad" ></telerik:RadEditor>

 <span id="charCountSpan" runat ="server" class="float-right"></span>



Cheers,
Samitha