Wednesday, 21 August 2013

How to create menu dynamically in Asp.Net Using Jquery.

In this article i will explain how to create a menu dynamically using jquery. The menu will create after click event of a button.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="htmltabs">
    </div>
    <style type="text/css">
        ul#tab
        {
            margin: 0;
            padding-left: 10px;
            list-style-type: none;
            background-image: url[ 'http://www.galaxyfinishingschool.com/images/coursepic-dotnet.jpg' ];
        }
        ul#tab li
        {
            display: inline;
            padding-left: 10px;
            text-decoration: none;
        }
        a
        {
            text-decoration: none;
            background-color: Gray;
            font-size: 20px;
            color: White;
        }
    </style>
    <script type="text/jscript">
        $(document).ready(function () {
            $("#btnTest").click(function () {
                var str1 = '<span>srinu</span>';
                var str = '<ul id="tab"><li ><a href="http://dotnettutorialblog.blogspot.in/">Dot Net Blog</a></li><li ><a href="https://www.google.co.in/" >GooGle</a></li><li ><a href="https://www.yahoo.com/" >Yahoo</a></ul>';
                $("#htmltabs").html(str);
                $("#btnTest").css("display", "none");

            });
        });
    </script>
    <input type="button" id="btnTest" value="Get Menu" />
    </form>
</body>
</html>

Thursday, 15 August 2013

How to Replace substring in a string.

 

Here i will give an example how to replace a substring in a string. For example you want to change email address in employee details table. 

In below example i am replacing  EmailId  from “@gmail.com” to ‘”@yahoo.com” in Employee Table .

-- Exmple 01.

declare @txt1 varchar(50)
set @txt1 = 'srinu.munagala33@gmail.com'
-- Here iam replacing @gmail.com to @yahoo.com
set @txt1 = REPLACE(@txt1, '@gmail.com', '@yahoo.com')

select @txt1
-- out put
-- srinu.munagala33@yahoo.com
-- Exmple 2.
/*
You can also update employee emailid in employee table.
*/

-- before EmailID = srinu.munagala33@gmail.com

update EmployeeDetals
set EmailID = REPLACE(EmailID, '@gmail.com', '@yahoo.com')
where EmployeeCode = 3151

-- After updating EmailID = srinu.munagala33@yahoo.com