• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

Kriztine Mendoza

Senior .NET Developer & Tech Partner for Scalable Software Solutions

  • Home
  • About
  • Work
  • Services
  • Contact Me

Dev Notes

The tooltip or Intellisense for methods do not appear!

January 17, 2019 by kriztine

The Story

One day, while I was doing my usual job of coding, I have noticed that when I type open parenthesis after the method name, the parameters do not appear automatically the way it used to.

I thought at first that my Visual Studio 2017 was just too slow. It’s been happening for quite some time, so I’ve tried restarting the Visual Studio, but the problem was not solved.

I’ve also tried deleting my user profile – nothing happened.

Finally, after a few days of being annoyed (and procrastinating to find the solution), I have found the fix!

(I have learned that the shortcut to display the method parameters is  Ctrl+Shift+Space. But, that is not what I want.)

 

The Fix

Go to TOOLS > Options > Text Editor > C# > General and check the Parameter Information.

 

Filed Under: .Net Development, How-To's

Scrollbar doesn’t show on Safari

November 5, 2018 by kriztine

The Story

One of the applications we are working on requires a modal popup to show the Terms and Conditions after the user registered to the app. Initially, the Accept and Decline buttons are disabled. The user should read the Terms and Conditions first before he/she can click a button. The user has to scroll down to the bottom of the page before the buttons become enabled. Now, we know that the Terms and Conditions are quite long, so the browser will automatically show a scrollbar.

However, the scrollbar is hidden in Safari browser by default. You can only see it when you scroll down using a mouse or touching the screen of your device. This can lead to confusion if the user sees the Terms and Conditions popup, but not being able to click the Accept or Decline button.

Solution

1. Use CSS to override the default scrollbar’s styling and visibility

/* Override the default to keep the scrollbar always visible */

::-webkit-scrollbar {
    -webkit-appearance: none;
    width: 8px;
}

::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 0 0 6px rgba(255,255,255,0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    border-radius: 4px;
    background-color: #8f8f8f;
    -webkit-box-shadow: inset 0 0 1px rgba(255,255,255,0.5);
}

2. Add a note at the bottom of the popup to inform the user to scrolldown to be able to read the full text.

 

Filed Under: .Net Development, Design Tagged With: css, Front-End Development

WebResource.axd File Compression

September 28, 2017 by kriztine

I was working on a custom .Net CMS that needs optimization.  To analyze the performance of a particular page, we were using the PageSpeed Insights and Pingdom tools.

The PageSpeed Insights recommends minifying JavaScript files. After I have bundled and minified all the js files in the system, PageSpeed is still reporting the issue due to the WebResource.axd files.

The application’s WebResource.axd files come from Telerik and ASP.Net page with server-side controls.

The Telerik’s WebResource.axd file is already minified, so I have just added the ScriptMode=”Release” tag.

<telerik:RadScriptManager ID="RadScriptManager1" runat="server" ScriptMode="Release"></telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager" runat="server">
</telerik:RadAjaxManager>

For the other WebResource.axd file, I had to create an HTTP module.

Implementation

  1. Write an HttpModule class named AxdCompressionModule.cs. After the axd files have been downloaded, it will be cached in the browser. The axd files will not be combined into a single file, though.
  2. Add settings to the web.config
<modules>
      <add name="AxdCompressionModule" type="ProjectName.Http.AxdCompressionModule, ProjectName" preCondition="managedHandler" />
</modules>

Filed Under: .Net Development, Tools Tagged With: ASP.Net Web Forms, PageSpeed Insights, Tools, Website Optimization

X-Frame-Options header and X-Content-Type-Options = nosniff

September 19, 2017 by kriztine

X-Frame-Options header

According to Mozilla documentation, the X-Frame-Options HTTP response header can be used to indicate whether or not a browser should be allowed to render a page in a <frame>, <iframe> or <object> . Sites can use this to avoid clickjacking attacks, by ensuring that their content is not embedded into other sites.

X-Content-Type-Options = nosniff

According to MSDN, the X-Content-Type-Options: nosniff is a security feature that helps prevent attacks based on MIME-type confusion. If the server sends this response header, the script and stylesheet elements will reject responses with incorrect MIME types.

Example of MIME-sniffing:

Consider the case of a picture-sharing web service which hosts pictures uploaded by anonymous users. An attacker could upload a specially crafted JPEG file that contained script content, and then send a link to the file to unsuspecting victims. When the victims visited the server, the malicious file would be downloaded, the script would be detected, and it would run in the context of the picture-sharing site. This script could then steal the victim’s cookies, generate a phony page, etc.

Implementation of X-Frame-Options header and X-Content-Type-Options = nosniff

In order to implement these two options into our project, we need to add the following code to the project’s web.config file:

<system.webServer>
   …
   <httpProtocol>
        <customHeaders>
            <remove name="X-Content-Type-Options">
            <add name="X-Content-Type-Options" value="nosniff">
            <add name="X-Frame-Options" value="SAMEORIGIN" >
        </customHeaders>
   </httpProtocol>
   …
</system.webServer>

After updating the web.config, here are the results of the HTTP headers for different browsers.

mozilla x-frame-options
Mozilla Firefox

 

CHROME x-frame-options
Google Chrome

 

edge x-frame-options
Microsoft Edge

Filed Under: System Administration and Configuration Tagged With: HTTP

Solved: Truncation Error when Importing from MS Excel to SQL Server

August 28, 2017 by kriztine

Issue

I was trying to import an Excel sheet with cells that contain very long strings (more than 256 characters) to SQL Server through the SQL Server Import Data Wizard.

What I have tried to do

Since the cells contain more than 256 characters, I have changed all varchar’s (or nvarchar) size to MAX. However, it did not solve the issue.

The Solution

Aside from changing the size to MAX, I have transferred one of the rows with a cell that has long strings to the first row so SQL Server would know that, indeed, a particular contains a very long string!

I have read somewhere that you can change something in the registry so SQL Server would automatically treat long strings as nvarchar(MAX), but I haven’t tried that yet.

 

Filed Under: SQL Tagged With: SQL Server

Filter Records using Dynamic SQL Query

August 2, 2016 by kriztine

The Story

I  want to search or filter records from the database based on some parameters like First Name, Company Name, Category etc.

However, using static or hard-coded SQL statement just won’t cut it. I need to write a dynamic SQL statement so I can use a flexible statement that is created and executed on-the-fly or on run-time.

Solution

First, I need to write a stored procedure that accepts different parameters.
Then, I am going to construct the dynamic SQL statement by concatenating strings.
Lastly, I am going to use the EXEC or sp_executesql to execute the created dynamic SQL statement.

Below is a sample implementation of dynamic SQL via stored procedure:


CREATE PROCEDURE [dbo].[PeopleSearch]
@FirstName nvarchar(250),
@LastName nvarchar(700),
@JobTitle varchar(300),
@EmailAddress varchar(300),
@CompanyName nvarchar(250),
@CompanyCity nvarchar(50),
@CompanyState nvarchar(50),
@CompanyZip nvarchar(50),
@Longitude decimal(11, 8),
@Latitude decimal(10, 8),
@Radius decimal(11, 8),
@Category smallint,
@ActiveEmpMin int,
@ActiveEmpMax int,
@CompanyEmailAddress varchar(3000),
@OperatorFlag bit = 0
AS
BEGIN

DECLARE @Where varchar(8000)
DECLARE @Operator varchar(6)
DECLARE @WildCard varchar(1)

IF @OperatorFlag = 0
BEGIN
SET @Operator = ' LIKE '
SET @WildCard = '%'
END
ELSE
BEGIN
SET @Operator = ' = '
SET @WildCard = ''
END

SET @Where = ''

IF LEN(ISNULL(@FirstName, '')) > 0
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 'p.FirstName' + @Operator + '''' + @WildCard + @FirstName + @WildCard + ''''
END

IF LEN(ISNULL(@LastName, '')) > 0
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 'p.LastName' + @Operator + '''' + @WildCard + @LastName + @WildCard + ''''
END

IF LEN(ISNULL(@JobTitle, '')) > 0
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 'p.JobTitle' + @Operator + '''' + @WildCard + @JobTitle + @WildCard + ''''
END

IF LEN(ISNULL(@EmailAddress, '')) > 0
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 'p.EmailAddress' + @Operator + '''' + @WildCard + @EmailAddress + @WildCard + ''''
END

IF LEN(ISNULL(@CompanyName, '')) > 0
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 's.SPONSOR_NAME' + @Operator + '''' + @WildCard + @CompanyName + @WildCard + ''''
END

IF LEN(ISNULL(@CompanyCity, '')) > 0
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 's.SPONSOR_CITY' + @Operator + '''' + @WildCard + @CompanyCity + @WildCard + ''''
END

IF LEN(ISNULL(@CompanyState, '')) > 0
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 's.SPONSOR_STATE' + @Operator + '''' + @WildCard + @CompanyState + @WildCard + ''''
END

IF LEN(ISNULL(@CompanyZip, '')) > 0
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 's.SPONSOR_ZIP' + @Operator + '''' + @WildCard + @CompanyZip + @WildCard + ''''
END

IF LEN(ISNULL(@Latitude, '')) > 0 AND LEN(ISNULL(@Longitude, '')) > 0 AND LEN(ISNULL(@Radius, '')) > 0
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + '(s.SPONSOR_LATITUDE Is Not Null AND s.SPONSOR_LONGITUDE Is Not Null)'
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
SET @Where = @Where + 'dbo.GetDistance(' + CONVERT(varchar, @Latitude) + ', ' + CONVERT(varchar, @Longitude) + ', CAST(s.SPONSOR_LATITUDE as float(8)), CAST(s.SPONSOR_LONGITUDE as float(8))) <= ' + CONVERT(varchar, @Radius)
END

IF @Category IS NOT NULL
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 's.SPONSOR_BUSINESS_CODE' + ' = ' + @Category
END

IF @ActiveEmpMin IS NOT NULL
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 'd.Total_Active_Participants' + ' >= ' + CONVERT(varchar, @ActiveEmpMin)
END

IF @ActiveEmpMax IS NOT NULL
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 'd.Total_Active_Participants' + ' <= ' + CONVERT(varchar, @ActiveEmpMax)
END

IF LEN(ISNULL(@CompanyEmailAddress, '')) > 0
BEGIN
IF LEN(@Where) > 0
SET @Where = @Where + CHAR(13) + CHAR(9) + 'AND '
ELSE
SET @Where = @Where + CHAR(13) + 'WHERE '
SET @Where = @Where + 'c.EmailAddress' + @Operator + '''' + @WildCard + @CompanyEmailAddress + @WildCard + ''''
END

DECLARE @Query varchar (MAX)

SET @Query =
'SELECT p.FirstName, p.LastName, p.JobTitle, e.EmailAddress, e.Verified, p.PrimaryContact, p.IsAdmin, p.Url, p.BloombergKeyExecUrl, p.ProfileId
FROM PeopleData d
INNER JOIN Sponsors s
ON d.SPONSOR_ID = s.SPONSOR_ID
INNER JOIN Contacts.Companies c
ON s.SPONSOR_EXTID = c.ExtId
INNER JOIN Contacts.People p
ON c.ExtId = p.ExtId
INNER JOIN Contacts.EmailAddresses e
ON p.ProfileId = e.ProfileId' +
@Where

EXEC (@Query)

END

Filed Under: SQL Tagged With: T-SQL

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to Next Page »

Primary Sidebar

Recent Posts

  • The tooltip or Intellisense for methods do not appear!
  • Scrollbar doesn’t show on Safari
  • WebResource.axd File Compression
  • X-Frame-Options header and X-Content-Type-Options = nosniff
  • Solved: Truncation Error when Importing from MS Excel to SQL Server

Categories

  • .Net Development (7)
  • Design (4)
  • How-To's (3)
  • Marketing (1)
  • Project Management (2)
  • Projects (1)
  • SQL (4)
  • System Administration and Configuration (2)
  • Tools (8)

Archives

SERVICES
  • Responsive Web Design
  • Custom Web/Software Development
  • Content Management System
  • API Development and Integration
  • Database Design and Management
  • System Configuration and Administration
QUICK LINKS
  • About
  • Services
  • Dev Notes
  • Resources
  • Contact me
GET IN TOUCH
  • +6349.539.1339
  • contact@kriztine.com
  • kriztine.tech@gmail.com

© 2025 · All Rights Reserved · Kriztine Mendoza

Attributions · Privacy Policy

"Whatever you do, work at it with all your heart, as working for the Lord..." - Colossians 3:23