Tuesday, February 10, 2015

Facebook LIKE BUTTON IN ASP.NET

Go to the developers WebSite of Facebook

https://developers.facebook.com/

The Following Screen is displayed





Click on Docs



  1. In Docs Click on Sharing



  1. In Sharing Clik on Social Plugins





Click on Like Button (Web)





The Following Screen is Displayed.




Now, Click on Get Code Button.





Now, Click on Get Code.




Copy the Javascript Code 

<div id="fb-root"></div>
<script>(function(d, s, id) {
  var js, fjs = d.getElementsByTagName [0];
  if (d.getElementById(id)) return;
  js = d.createElement ; js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.0";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>


Now, Open Visual Studio 


File-> New- Website




Click on Asp.net Empty Web Site.



Add-> Add New Item






Write the Following Code


<head runat="server">
    <title></title>
</head>
<body>
    <div id="fb-root"></div>
    <script>(function (d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

    <form id="form1" runat="server">
    <div>
        <div class="fb-comments" data-href="https://developers.facebook.com/docs/plugins/" data-numposts="10" data-colorscheme="light"></div>
    </div>
    </form>
</body>

</html>


Run,and see the output.








Monday, February 9, 2015

GOOGLE MAPS

Design the Form as Follows





Design Code

 <div>
    <table>
        <tr>
            <td> Area </td>
            <td> <asp:TextBox ID="txtArea" runat="server"></asp:TextBox> </td>
        </tr>
        <tr>
             <td> City </td>
            <td> <asp:TextBox ID="txtCity" runat="server"></asp:TextBox> </td>
        </tr>
        <tr>
            <td> <asp:Button ID="Button1" runat="server" Text="Search"  OnClick="ButtonSearch_Click"/> </td>
        </tr>
    </table>
    </div>


.cs Page










output



Thursday, February 5, 2015

SHOW ALERT POP UP REMAINDER SCHEDULAR USING MASTER PAGE.

File->New->WebSite




Master Page Design




Design

<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div>
            <table>
                <tr>
                    <td>Uday Blog Spot
                    </td>
                    <td>http://dotnetbyudayrajakonda.blogspot.in/
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
                    </td>
                </tr>
            </table>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            </asp:UpdatePanel>
            <asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick"></asp:Timer>
        </div>
        <div class='popup' style="position: fixed; margin-right: 50px; width: 300px; height: 200px" id="divRemainder">

            </div>
    </form>
</body>


styles

  <style type="text/css">
        .popup{
               background-color: #F4F4F4;
    border: 7px solid #545353 !important;
    border-radius: 5px 5px 5px 5px;
    -webkit-box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
    -moz-box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
    box-shadow: 0 1px 12px rgba(0, 0, 0, 0.6);
    display: none;
        }

        .content {
            min-width: 600px;
            width: 600px;
            min-height: 150px;
            margin: 100px auto;
            background: #f3f3f3;
            position: relative;
            z-index: 103;
            padding: 10px;
            border-radius: 5px;
            box-shadow: 0 2px 5px #000;
            margin-right: 42%;
        }
    </style>

java script function

  <script type="text/javascript">
        function myFunction() {
            var string = MasterPage2.RemainderDetails();
            $('#divRemainder').append(string.value);
            $('.popup').show();
            return false;
        }

    </script>


MasterPage.cs




 [Ajax.AjaxMethod(Ajax.HttpSessionStateRequirement.Read)]
    public string RemainderDetails()
    {
        SqlConnection con = new SqlConnection("");
        SqlCommand cmd = new SqlCommand("", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataTable _dataTable = ds.Tables[0];
        StringBuilder sb = new StringBuilder();
        int count = _dataTable.Rows.Count;
        if (count > 0)
        {
            sb.Append("<table width='100%' cellspacing='0' cellpadding='0' border='0'>");
            sb.Append("<thead  class='tableHeadBg'><tr>");
            sb.Append("</tr></thead>");
            sb.Append("<tbody class='tableTbodyBg'>");
            for (int i = 0; i < count; i++)
            {
                sb.Append("<tr>");
                sb.Append("<td width='10%' align='left'>");
                sb.Append(Convert.ToString(_dataTable.Rows[i]["Appointment"]));
                sb.Append("</td>");
                sb.Append("<td width='10%' align='left'>");
                sb.Append(Convert.ToString(_dataTable.Rows[i]["RemainderStartDate"]));
                sb.Append("</td>");
                sb.Append("</tr>");
            }
            sb.Append("</tbody></table>");
        }
        return sb.ToString();
    }


Add Content Page as Follows







Content Page




contentPage.cs(Need not write any code in Default Page as the code  need to be written in Master Page.

\
Output:



CALL AJAX METHODS FROM JAVASCRIPT

Add Ajax dll 
Import the AJAX namespace from Ajax.DLL.

File->New->WebSite





Add Ajax dll (Add Reference of Ajax.dll)








Design the Form as Follows

 <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <table>
                <tr>
                    <td>Country </td>
                    <td><asp:DropDownList ID="ddlCountry" runat="server" ></asp:DropDownList></td>
                </tr>
                <tr>
                    <td>City </td>
                    <td> <asp:DropDownList ID="ddlCity" runat="server"></asp:DropDownList></td>
                </tr>
                <tr>
                    <td> <asp:Button ID="btnSave" runat="server" Text="save" OnClientClick="save()" /> </td>
                </tr>
            </table>
    </form>




Javascript Code

<script src="http://code.jquery.com/jquery-1.8.3.min.js">  </script>
    <script src="jquery-1.7.min.js"></script>
    <script type="text/javascript">
        $('#ddlCountry').live('change', function () {
            var rst = Default2.BindCities($(this).val()).value;
            $('#ddlCity').html(rst);
        })
    </script>







web.config

<configuration>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <httpHandlers>
      <add verb="POST,GET" path="ajax/*.ashx" type="Ajax.PageHandlerFactory, Ajax"/>
    </httpHandlers>
    <httpModules>
      <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    </httpModules>
  </system.web>

</configuration>





.cs Page

Namespaces

using Ajax;

using System.Data.SqlClient;


protected void Page_Load(object sender, EventArgs e)
    {
        Ajax.Utility.RegisterTypeForAjax(typeof(Default2));
        SqlConnection con = new SqlConnection("------------");
        SqlCommand cmd = new SqlCommand("------", con);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        ddlCountry.DataSource = ds;
        ddlCountry.DataTextField = "Country";
        ddlCountry.DataValueField = "ID";
        ddlCountry.DataBind();
        ddlCountry.Items.Insert(0, new ListItem("SelectItem", "0"));
    }



[Ajax.AjaxMethod(HttpSessionStateRequirement.ReadWrite)]
    public string BindCities(int countryid)
    {
        StringBuilder _stringBuilder = new StringBuilder();
        try
        {
            SqlConnection con = new SqlConnection("----");
            SqlCommand cmd = new SqlCommand("", con);
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            da.Fill(ds);
            _stringBuilder.Append("<option value='0'> -SELECT-</option>");
                if (ds != null && ds.Tables != null && ds.Tables[0] != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    _stringBuilder.Append("<option value='" + ds.Tables[0].Rows[i]["ID"].ToString() + "'>" + ds.Tables[0].Rows[i]["CityCode"].ToString() + "</option>");
                }
            }
            return _stringBuilder.ToString();
        }
        catch (Exception Ex)
        {
            return Ex.Message.ToString();
        }

    }

Output:


Wednesday, February 4, 2015

JQUERY CLIENT SIDE VALIDATIONS

To get TextBox value without Master Page
var firstName = $('#txtFirstName').val()

To get TextBox value with MasterPage for TextBox
var subject = $(GetClientID('CallsSubjectTxt')).val();

To get drop down Text with Master Page
var callType = $(GetClientID('CallTypeDrp')).find('option:selected').text();

To get drop down Text without Master Page
var countryText = $('#DropDownList1').find('option:selected').text()

To get drop down Id without Master Page
var callTypeID = $('#CallTypeDrp')).val()

To get drop down Id with Master Page
var callTypeID = $(GetClientID('CallTypeDrp')).val()


To check checkbox validation with Master Page
if ($(GetClientID('RemainderChk')).is(':checked'))
            RemainderCheck = 1;
        else
            RemainderCheck = 0;

To check checkbox validation without Master Page
if ($('#RemainderChk')).is(':checked'))
            RemainderCheck = 1;
        else
            RemainderCheck = 0;


To find out all checked check boxes

$("input[type='checkbox']:checked").each(
    function() {
       // Your code goes here...
    }
);



var isChecked = $('#chkSelectBox').attr('checked')?true:false;
Here if check box is checked it returns true, else undefined




var isChecked = $('#chkSelectBox').prop('checked');

prop() will return true or false 





Label Validations:



<head runat="server">
    <title></title>
    <script src="jquery-1.7.min.js"></script>
    <script type="text/javascript">
            $(document).ready(function () {
                var lablevalue = $('#Label1').text();
                alert('Label Value ' + lablevalue);
            });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="divClassusingID" style="width:400px"> 
        <asp:Label ID="Label1" runat="server" Text="hi uday"></asp:Label>

    </div>
    </form>
</body>



output:




To get label value with master page

$('#<%=Label1.ClientID%>').text();


To get label value without master page
$('#Label1').text();

-----------------------------------------------------------------------------------------

Set label value with master page
$('#<%=Label1.ClientID%>').text("New Value");


Set label value without master page

$('#Label1').text("dotnetbyudayrajakonda.blogspot.in");


Example:


<head runat="server">
    <title></title>
    <script src="jquery-1.7.min.js"></script>
    <script type="text/javascript">
            $(document).ready(function () {
                var lablevalue= $('#Label1').text("dotnetbyudayrajakonda.blogspot.in");
            });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="divClassusingID" style="width:400px"> 
        <asp:Label ID="Label1" runat="server" Text="hi uday"></asp:Label>
    </div>
    </form>
</body>





Output:





Set Textbox value with Master Page
$('#<%=TextBox1.ClientID%>').val("New Value");

Set Textbox value without Master Page
$('#TextBox1').val("HI uday");


<head runat="server">
    <title></title>
    <script src="jquery-1.7.min.js"></script>
    <script type="text/javascript">
            $(document).ready(function () {
                var a=$('#TextBox1').val("HI uday");
            });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="divClassusingID" style="width:400px"> 
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>
    </form>
</body>



Output:

Set Dropdown value with Master Page
$('#<%=DropDownList1.ClientID%>').val("hi");

Set Dropdown value without Master Page
$('#DropDownList1').val("hi");

Get text of selected item in dropdown with Master Page
$('#<%=DropDownList1.ClientID%> option:selected').text();

Get text of selected item in dropdown without Master Page
$('#DropDownList1 option:selected').text()

Make textbox as Read only
$('#TextBox1').attr('readonly', 'readonly');


<head runat="server">
    <title></title>
    <script src="jquery-1.7.min.js"></script>
    <script type="text/javascript">
            $(document).ready(function () {
                $('#TextBox1').attr('readonly', 'readonly');
            });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="divClassusingID" style="width:400px"> 
        <asp:TextBox ID="TextBox1" runat="server" ></asp:TextBox>
    </div>
    </form>
</body>


To disable texbox



Using check box
$('#CheckBox1').attr('checked');





output:



Example:







Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...