Wednesday, March 15, 2017

How to Highlight Searching Contents of Web Page

Tags: How to Search any text in whole web page using Jquery

 Hello Readers, today we will learn that how to search any content in web page and highlight that.
To achieve this, we will use J Query mark.js script file. You can download it from here or any trusted source you know.

Editor : You can use any editor to try this example like notepad, notepad++, bracket or Visual Studio. I suggest to use Visual Studio because it has great feature of Intellisense which helps you to get suggestions and type quick.

Steps – 
Create a New Website in Visual Studio. File menu > New > Web Site


Right click on Project in Solution Explorer > Add > Add New Item Option



Select HTML Page Template


Give name Default.html > ADD Button. Following display will come.


Now right click on Project from Solution Explorer > Add > Existing Item… option


Now Add two important script files from the place where you have downloaded. See Image Below

Include these two JS files into <head> section of your page.

Now add script and other required code in the page by copy and paste from below code :

<!DOCTYPE html>
<html>
<head>
    <title>Highlight Search</title>
       <meta charset="utf-8" />
   
    <script src="jquery.min.js"></script>
    <script src="jquery.mark.min.js"></script>
   
    <script>
        $(document).ready(function (){
        var mark = function () {
        // Read the keyword
            var keyword = $("input[name='keyword']").val();
        // Determine selected options
            var options = {};
            $("input[name='opt[]']").each(function () {
                options[$(this).val()] = $(this).is(":checked");
            });
            // Remove previous marked elements and mark
            // the new keyword inside the context
            $(".context").unmark({
                done: function () {
                    $(".context").mark(keyword, options);
                }
            });
        };

        $("input[name='keyword']").on("input", mark);
        $("input[type='checkbox']").on("change", mark);
        });
    </script>
</head>
<body>
    <div>
        <span>
            <input id="btnQuickSearch" type="button" value="QUICK SEARCH" />
        </span>
        <input type="text" name="keyword" style="width:300px;" placeholder="Enter Keyword Here...">

        <span>Search Options:</span>
        <input type="checkbox" name="opt[]" value="separateWordSearch" checked> Separate Word Search
        <input type="checkbox" name="opt[]" value="diacritics" checked> Diacritics
    </div>
    <br />
    <br />
    <div id="divQuickSearch" class="context">
        This is the text for the searching Test.
    </div>
</body>
</html>

About above code: You should be careful about the name and class attribute of controls. Because in script code, the action is performed with the help of these attributes. Have look on following images:


Save and view the page in browser, following view will display:


When you will type the text in the box, the content will highlight. See output below:

You can apply this script for other tags like table, span, p etc.

Happy Coding
I hope this will help. Send me your feedback/suggestions/queries.

Rudra Pratap Singh
Software Engineer


Tuesday, February 14, 2017

Difference between Build, Rebuild and Clean an entire solution in Visual Studio IDE

Hello Readers,
आज हम Visual Studio IDE के most using options के बारे में जानेंगे | Build Menu में दिए हुए Build, Rebuild and Clean options |



ये options Solution Explorer window में Solution पर  Right Click करने पर भी मिलते हैं |



1- जब हम Build या Build Solution option का use करते हैं  तो केवल वो projects files और components compile होते हैं जिनमे  last time build करने के बाद change किया गया है |
For example, अगर आज अपने solution को build किया है और उसके बाद two files में change हुआ है तो केवल 2 files ही compile होंगी |

2- जब  हम Rebuild Solution option का use करते हैं तो सारी project files और  components scratch से compile होते हैं |

3- जब हम Clean solution option का use करते हैं तो सारी intermediate और output files delete हो जाती हैं और केवल प्रोजेक्ट्स and component files बचती हैं |

For example, कभी कभी जब project में कही break point work नहीं करता है तो  हम Clean Solution option का use करते हैं |


 उम्मीद करता हूँ कि ये लेख आपके लिए मददगार होगा |


अपना feedback/suggestions अवश्य दें | मुझे मेल करें |


Rudra Pratap Singh
Software Engineer

Tuesday, January 31, 2017

How to check if a Table exists in SQL Server

Tags:  How to check table existence in SQL Server, what is OBJECT_ID function in SQL Server, Different approaches to check table existence in SQL Server,  information_schema.tables.

कभी कभी SQL Server पर काम करते समय हमें check करवाना होता है कि कोई table exist करती है या नहीं, ऐसे scenario में हम कई approaches प्रयोग कर सकते हैं | आईये उनको देखते हैं

मान लीजिये कि हमारे database का name DBFirst  है और उसमे एक table है जिसका name Employee है | हम इस table कि existence check करेंगे |

तरीका 1: INFORMATION_SCHEMA.TABLES का प्रयोग करके:
IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES
           WHERE TABLE_NAME = N'Employee')
BEGIN
  PRINT 'This Table Exists'
END



तरीका 2: OBJECT_ID() Function का प्रयोग करके:

IF OBJECT_ID('dbo.Employee') IS NOT NULL
BEGIN
  PRINT 'This Table Exists'
END



तरीका 2 में dbo लगाना जरुरी नहीं है | यह optional है |

उम्मीद करता हूँ कि ये लेख आपके लिए मददगार होगा |

अपना feedback/suggestions अवश्य दें | मुझे मेल करें |

My Youtube Channel – Click Here

Rudra Pratap Singh

Software Engineer

How to Get Organic Views on Your Channel/Content

 Hi Friends, This post will be very short and specific in the information.  If you are a content creator and want some help in getting organ...