Thursday, February 23, 2023

How to import .js in .NetCore website project

1) imports in  site.scss

@import "../node_modules/dropzone/src/basic.scss";

@import "../node_modules/dropzone/src/dropzone.scss";

it will be included in wwwroot/lib  

2)change Directory.Build.props file

<NpmSourceJsFiles Include="node_modules/dropzone/dist/dropzone.js;node_modules/dropzone/dist/min/dropzone.min.js" />

3) package.json

{

  "version": "1.0.0",

  "name": "asp.net",

  "private": true,

  "devDependencies": {

     "@types/dropzone": "5.7.4",   

    "dropzone": "5.9.3"

  }

}

4)package-lock.json

  "@types/dropzone": {

      "version": "5.7.4",

      "resolved": "https://registry.npmjs.org/@types/dropzone/-/dropzone-5.7.4.tgz",

      "integrity": "sha512-9kLJ2YAmVRWYrHvDoa95pQzHF0HUMKcznsS7FM1Mht5Yieec+HMB6Ybfm+ocvLjvFCvgyYGFTp4nzNFxhZmo3g==",

      "dev": true,

      "requires": {

        "@types/jquery": "*"

      }

    },

5)convert .js to .ts and store under /Scripts folder

it will be inlcuded under wwwroot/js after compilation

Wednesday, March 28, 2018

CHECK ROWS IN ALL DATABLE

SELECT QUOTENAME(SCHEMA_NAME(sOBJ.schema_id)) + '.' + QUOTENAME(sOBJ.name) AS [TableName]
      , SUM(sPTN.Rows) AS [RowCount]
FROM
      sys.objects AS sOBJ
      INNER JOIN sys.partitions AS sPTN
            ON sOBJ.object_id = sPTN.object_id
WHERE
      sOBJ.type = 'U'
      AND sOBJ.is_ms_shipped = 0x0
      AND index_id < 2 -- 0:Heap, 1:Clustered
GROUP BY
      sOBJ.schema_id
      , sOBJ.name
ORDER BY 2 desc

Wednesday, February 28, 2018

Optional scripts bundle

       
#if DEBUG
            BundleTable.EnableOptimizations = false;
#else
            BundleTable.EnableOptimizations = true;
#endif

Tuesday, February 13, 2018


--Deploy resource file for unit test
     
Add << >> before and end
DeploymentItem("..\..\App_LocalResources\myControl.ascx.resx")
    Public Sub CheckResourceKey()
        Dim resourcePath As String = Path.Combine(Environment.CurrentDirectory, "myControl.ascx.resx")
   
          Dim lblResourceKey As String
          Dim xmlDoc As New Xml.XmlDocument

           xmlDoc.Load(resourcePath)
           Dim keyName As String = "myname"
       
            lblResourceKey = GetResourceValueByName(xmlDoc, "data", keyName)

    End Sub



Tuesday, August 02, 2016

function stopPropagation(evt) {
    if (typeof evt.stopPropagation == "function") {
        evt.stopPropagation();
    } else {
        evt.cancelBubble = true;
    }
}
e.preventDefault()

Monday, April 14, 2014

close window after executing code on server side in Button.Click event




   /Java script
        function CloseWindow() {
            setTimeout(function () {
                GetRadWindow().close();
            }, 0);
        }

        function GetRadWindow() {
            var oWindow = null; if (window.radWindow)
                oWindow = window.radWindow; else if (window.frameElement.radWindow)
                    oWindow = window.frameElement.radWindow; return oWindow;
        }
    /End of Java script

        Protected Sub btnOK_Click(sender As Object, e As EventArgs) Handles btnOK.Click
            'Server side code
             'Close  window
            ScriptManager.RegisterStartupScript(Page, Me.GetType(), "close", "CloseWindow();", True)
        End Sub

Thursday, March 11, 2010

SQLExpress Login 'sa' failed for credential issue

http://www.techurbia.com/2009/03/cannot-set-a-credential-for-principal-sa-sql-server-20052008.html

On Security->Logins->sa property page:
Step 1:Make sure "Map to credential" is checked


Step 2:change password
step 3:in "status" tab, make sure "login" is enabled.
Step 4: Servr Property->Security, make sure "SQL Server and Windows Authentication Mode" is checked



Step 5: Stop and Start SQLExpress Service

Friday, February 26, 2010

Autodesk.AutoCAD.Interop.Common.dll Reference

Some AutoDesk Assembly files in GAC:
acax18enu.tlb AutoCAD 2010 Type Library
axdb18enu.tlb Autodesk.AutoCAD.Interop.Common.dll

File path:

Thursday, February 04, 2010

AutoCAD Dynamic Input

Toolbar on the bottom left,"Dynamic Input" to hide or display the command/message on the drawing.

Tuesday, November 24, 2009

拭目以待

You can fool all the people some of the time, some of the people all the time, but you cannot fool all the people all the time.

Wednesday, November 04, 2009

Dynamic SQL Excute

declare @tablename char(10)
declare @columnname char(10)
set @tablename='myTable'
set @columnname='myColumn'
execute('select * from ' + @tablename + ' order by ' + @columnname)

Tuesday, November 03, 2009

Copy selective columns of data table to another datatable - VB.NET Articles, samples and tutorials

Dim DestTable As DataTable = new DataTable

Dim NewColumns() As String={"EmpID","FirstName "}

DestTable = sourceTable.DefaultView.ToTable("TableName", false, strColsToExport)

Thursday, September 03, 2009

Example Web.config files for LDAP forms-based authentication

http://technet.microsoft.com/en-us/library/cc197251.aspx

Tuesday, August 04, 2009

Adding Web User Control To A Class Library

open the project file(*.vbproj) in a text editor

find this line or add it: (replace [ with <, ] with >)[ProjectTypeGuids]{349c5851-65df-11da-9384-00065b846f21};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}[/ProjectTypeGuids]
Add it below [ProjectGuid]

The project type guids for c# are as below.
{349c5853-65df-11da-9384-00065b846f21};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}

Tuesday, June 02, 2009

sp_change_users_login

When database is restored from other back file but login user can't be assigned to the restored database, run following:


USE tablename
GO
EXEC sp_change_users_login 'Update_One', 'username', 'username';

Relative link:
http://msdn.microsoft.com/en-us/library/ms174378.aspx

Tuesday, April 07, 2009

Format date

http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx

VB.NET

format(Convert.ToDateTime("2004/7/1 23:46"), "yyyy-MM-dd HH:mm")

Tuesday, March 24, 2009

Add validation property to UserControl

[ValidationPropertyAttribute("Text")] _
[ControlValuePropertyAttribute("Text")] _
Public Class textUpload
Inherits System.Web.UI.UserControl

Public Property Text() As String
Get
Return txtName.Text
End Get
Set(ByVal value As String)
txtName.Text = value
End Set
End Property
End Class

ps: remember to replace [] with <>

Friday, February 27, 2009

How to retrieve GUID inserted in a database table?

Using Stored Procedure Output parameter to return the GUID generated in the database.
(UniqueIdentifier has function NEWSEQUENTIALID() to generate a sequential GUID)
----------------
INSERT INTO myTable (columna) OUTPUT INSERTED.GUIDColumn VALUES(@columna)
----------------

INSERTED is a table created by Insert Trigger.



From:
http://blog.jemm.net/articles/databases/how-to-using-sql-server-2005s-output-to-return-generated-identity/

Wednesday, February 18, 2009

SVC and EndPoint

A *.svc file on the WCF host server has following declaration:

《 %@ ServiceHost Service="SilverService" Debug="true" % 》

Service "SilverService" is also defined in the web.config file "system.serviceModel"-"services" section. Usually it's a name extracted from a DLL class.

"SilverService" is the name of the service, and the service needs to define an EndPoint which has ABC(Address, Binding,Contract)

Contract points to the Interface of a service.

Call WCF Service Operations Asynchronously

Private nor As SilverService.SilverServiceClient = Nothing

Options 1: Begin/End event
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
Dim pat As New PageAsyncTask(AddressOf BeginGetDataAsync, AddressOf EndGetDataAsync, Nothing, Nothing)
Page.RegisterAsyncTask(pat)
End Sub

Private Function BeginGetDataAsync(ByVal sender As Object, ByVal e As EventArgs, ByVal acb As AsyncCallback, ByVal extraData As Object) As IAsyncResult
nor = New SilverService.SilverServiceClient()
Return nor.BeginGetData("Limin", acb, extraData)
End Function

Private Sub EndGetDataAsync(ByVal ar As IAsyncResult)
lblInfo.Text = nor.EndGetData(ar)
End Sub



Option 2: Completed Event
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
nor = New SilverService.SilverServiceClient()
AddHandler nor.GetDataCompleted, AddressOf Client_GetDataCompleted
nor.GetDataAsync("Limin")
End Sub

Private Sub Client_GetDataCompleted(ByVal sender As Object, ByVal e As SilverService.GetDataCompletedEventArgs)
lblInfo.Text = e.Result.ToString
nor = Nothing
End Sub

Blog Archive