Thursday, April 26, 2012

Label ToolTip using Jquery


<style type="text/css">
            /* HOVER STYLES */
            div#question
            {
                display: none;
                position: absolute;
                width: 200px;
                padding: 10px;
                background: Ivory;
                color: #000000;
                border: 1px solid skyblue;
                font-size: 90%;
            }
            .thumbnail-item
            {
                /* position relative so that we can use position absolute for the tooltip */
                position: relative;
                float: left;
                margin: 0px 5px;
            }
        </style>
        <script type="text/javascript">
            Sys.Application.add_load(function () {
                var moveLeft = 2;
                var moveDown = 10;

                $('a#trigger').hover(function (e) {
                    $('div#question').show();
                }, function () {
                    $('div#question').hide();
                });

                $('a#trigger').mousemove(function (e) {
                    $("div#question").css('top', e.pageY + moveDown).css('left', e.pageX + moveLeft);
                });

            });
        </script>




   <asp:Label runat="server" Style="text-align: center" ID="lblReturnRatio" Text="Return Ratio">
                                            </asp:Label>
                                            <a href="#" id="trigger" tabindex="100">
                                                <img alt="help" src="Images/question.jpg" height="13px" width="13px" />
                                            </a>:
                                            <!-- TOOLTIP -->
                                            <div id="question">
                                                <p>
                                                    This is the tool tip for Return Ratio and will be replaced by surgere definition.
                                                </p>
                                            </div>

Timeout Setting using Jquery


 <script language="javascript" type="text/javascript">
            function showWaitPack() {
                $get('<%=UpdateProgressPack.ClientID%>').style.display = 'block';
                setTimeout("disablePack();", 1000);
            }
            function disablePack() {
                var controls = document.getElementById("<%=pnlUnitLoadDataSheet.ClientID%>").getElementsByTagName("input");
                for (var i = 0; i < controls.length; i++)
                    controls[i].disabled = true;
                setTimeout("HideLabelPack();", 6000);
            }
            function HideLabelPack() {
                document.getElementById('<%= UpdateProgressPack.ClientID %>').style.display = "none";
                var controls = document.getElementById("<%=pnlUnitLoadDataSheet.ClientID%>").getElementsByTagName("input");
                for (var i = 0; i < controls.length; i++)
                    controls[i].disabled = false;
                if (document.getElementById('<%=rdbDirect.ClientID %>').checked == true) {
                    document.getElementById('<%=rdbCrossDock.ClientID %>').disabled = true;
                    document.getElementById('<%=rdbCrossDock.ClientID %>').checked = false;
                    document.getElementById('<%=rdbRepack.ClientID %>').disabled = true;
                    document.getElementById('<%=rdbRepack.ClientID %>').checked = false;
                }
            }
</script>

Dropdown binding using Jquery in VB.NET

In ASPX page:


<script type="text/javascript">
            var pageUrl = '<%=ResolveUrl("~/BOLSup.aspx")%>'
            function PopulateRecLoc() {
                $("#<%=comboFacility.ClientID%>").attr("disabled", "disabled");

                if ($('#<%=comboRecievingLocation.ClientID%>').val() == "0") {
                    $('#<%=comboFacility.ClientID %>').empty().append('<option selected="selected" value="0">Select</option>');

                }
                else {
                    $('#<%=comboFacility.ClientID %>').empty().append('<option selected="selected" value="0">Loading...</option>');
                    var reclocid = $('#<%=comboRecievingLocation.ClientID%>').val()
                    $("#<%= hdnreclocid.ClientID %>").val(reclocid);
                    var hval = document.getElementById('<%=hdnreclocid.ClientID %>').value;

                    $.ajax({
                        type: "POST",
                        url: pageUrl + '/PopulateFacility',
                        data: '{RecLocId: ' + $('#<%=comboRecievingLocation.ClientID%>').val() + '}',
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function OnCountriesPopulated(response) {

                            PopulateControl(response.d, $("#<%=comboFacility.ClientID %>"));
                        },
                        failure: function (response) {
                            alert(response.d);
                        }
                    });
                }
           

            function PopulateControl(list, control) {
                if (list.length > 0) {
                    control.removeAttr("disabled");
                    control.empty().append('<option selected="selected" value="0">Select</option>');
                    $.each(list, function () {
                        control.append($("<option></option>").val(this['Value']).html(this['Text']));
                    });
                }
                else {
                    control.empty().append('<option selected="selected" value="0">Not available<option>');
                }
            }
        </script>




    <asp:DropDownList runat="server" ID="comboRecievingLocation" Width="205Px" onchange="PopulateRecLoc()"
                                                                    CausesValidation="false">
                                                                </asp:DropDownList>






Imports System
Imports System.Collections.Generic
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Configuration
Imports System.Data.SqlClient
Imports System.Data
Imports System.Collections
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.Collections.Specialized
Imports AjaxControlToolkit
Imports System.Web.SessionState

Public Class BOLSup
    Inherits System.Web.UI.Page
    Implements IRequiresSessionState
 
 
    <System.Web.Services.WebMethod()> _
    Public Shared Function PopulateFacility(ByVal RecLocId As Integer) As ArrayList
        Dim list As ArrayList = New ArrayList
        Dim strConnString As String = ConfigurationManager.ConnectionStrings("SurgereConnection").ConnectionString
        Dim strQuery As String = "select facility_id,facility_name from Facility where facility_type<>'Consolidation Center' and location_id=@location_id"
        Dim con As SqlConnection = New SqlConnection(strConnString)
        Dim cmd As SqlCommand = New SqlCommand
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@location_id", RecLocId)
        cmd.CommandText = strQuery
        cmd.Connection = con
        con.Open()
        Dim sdr As SqlDataReader = cmd.ExecuteReader
        While sdr.Read
            list.Add(New ListItem(sdr("facility_name").ToString, sdr("facility_id").ToString))
        End While
        con.Close()
        Return list
    End Function
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

 


Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...