Monday, 11 February 2019

MVC Material design check box not showing

///////////////////////////// HTML

                    /////////// CSS
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.css" />

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.96.1/css/materialize.min.css" />

<from>
          <p>
                <input type="checkbox" id="test6" />
          </p>
         
            <p>
                <input type="checkbox" id="test6" />
                <input name="test5" type="hidden" value="false">
                <label for="test6">Test</label>

            </p>
</from>



/////////////////////////JS

             <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0/jquery.js"></script>    

      <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.96.1/js/materialize.min.js"></script>

<script>

          $(document).ready(function () {
              $('input[type=checkbox]').each(function () {
                  if (this.nextSibling.nodeName != 'label') {
                      $(this).after('<label for="' + this.id + '" style</label>')
                  }
              })
          })

      </script>




//////////////// Result




Wednesday, 6 February 2019

Get query string data in mvc

////////////////////// LoginController


using GoNoise.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data;
using System.Web.UI;

namespace LoginTest.Controllers
{
    public class LoginController : Controller
    {


public string VerifyUserEmail(string id,string Email)
        {
            SqlParameter[] parmdel = new SqlParameter[]
                   {
                   new SqlParameter("@UserEmailID",Email),
                   new SqlParameter("@EmailOTP",id)

                  };
            int result = ConnectionClass.ExecuteNonQuery(ConnectionClass.con, CommandType.StoredProcedure, "sp_userverify_Email", parmdel);
            string msg = "Invalid OTP, Please try again.";
            if (result>0)
            {
                msg = "Email verification is completed";
            }
            return "<div style='font-size: 20px;color: green;position: absolute;top: 20%;left: 35%; border: solid 1px #bfdac0;padding: 20px 30px; '> <img src='../images/done.png' / style=margin-right: 12px; margin-bottom: -9px;'>" + msg+"</div>";
        }
   }
}

///////////////////// HTML new page

@{

    Layout = null;
} 
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>VerifyUserEmail</title>
</head>
<body>
   
</body>
</html>





Tuesday, 5 February 2019

Reset bootstrap multi-select dropdownlist using jquery

///////////////////////////////// HTML


<select size="4" multiple="multiple" id=" ddl_Stations" class="multiselect">
                     <option value="Alagawadi">Alagawadi</option>
                     <option value="Attigundi">Attigundi</option>
                     <option value="Balehonnur.M">Balehonnur</option>
                     <option value="Bannur">Bannur</option>
                     <option value="Bennur">Bannur</option>
                     <option value="Chandapur">Chandapur</option>
                     <option value="Chapoli (M)">Chapoli</option>
                     <option value="Chikkalgud">Chikkalgud</option>
                     <option value="Chincholi.M">Chincholi</option>

              </select>



//////////////////////////////// JS


<script>

function Fill_DropdownLists(fnName) {
                        $.ajax({
                            type: 'POST',
                            dataType: 'json',
                            contentType: 'application/json; charset=utf-8',
                            url: Page.aspx/' + fnName,
                            data: ''
                            dataType: "json",
                            success: function (data) {
                                debugger;
                                var $ddls = $('[id$=' + ddlFillID + ']');
                                $ddls.empty();
                                $.each(data.d, function () {
                                    $ddls.append($("<option></option>")
                                         .val(this['id']).html(this['Name']));
                                });
                           $ddls.multiselect('destroy');////destroy ul li from select option
                                Ddl_Multiselect(ddlFillID);///bind again multiselect
                            },
                            error: function (result) {
                                alert("Error");
                            }
                        });
                    }

function Ddl_Multiselect(ddlFillID) {
                                            $('[id$='+ddlFillID+']').multiselect({
                                                enableFiltering: true,
                                                maxHeight: 400,
                                                enableCaseInsensitiveFiltering: true,
                                                nonSelectedText: 'Select Stations',
                                                numberDisplayed: 2,
                                                selectAll: false,
                                                onChange: function (option, checked) {
                                                    // Get selected options.
                                                    var selectedOptions = jQuery('.multiselect option:selected');

                                                    if (selectedOptions.length >= 5) {
                                                        // Disable all other checkboxes.
                                                        var nonSelectedOptions = jQuery('.multiselect option').filter(function () {
                                                            return !jQuery(this).is(':selected');
                                                        });

                                                        nonSelectedOptions.each(function () {
                                                            var input = jQuery('input[value="' + jQuery(this).val() + '"]');
                                                            input.prop('disabled', true);
                                                            input.parent('li').addClass('disabled');
                                                        });
                                                    }
                                                    else {
                                                        // Enable all checkboxes.
                                                        jQuery('.multiselect option').each(function () {
                                                            var input = jQuery('input[value="' + jQuery(this).val() + '"]');
                                                            input.prop('disabled', false);
                                                            input.parent('li').addClass('disabled');
                                                        });
                                                    }
                                                }
                                            });
                                        }

                </script>


Open PDF file in web browser new tab

////////////////////////////HTML


<asp:GridView runat="server" ID="GV_ViewPdf" AutoGenerateColumns="false" CssClass="table table-striped table-bordered table-hover table-responsive grd3">
                                    <Columns>
                                        <asp:TemplateField HeaderText="SNo.">
                                            <ItemTemplate>
                                                <%#Container.DataItemIndex+1 %>
                                            </ItemTemplate>
                                            <ItemStyle Width="5%" />
                                            <HeaderStyle Width="5%" />
                                        </asp:TemplateField>
                                        <asp:TemplateField HeaderText="File Names">
                                            <ItemTemplate>
                                                <asp:LinkButton runat="server" ID="Lbtn_ViewPdf" OnClick="Lbtn_ViewPdf_Click" Text='<%#Eval("FileName") %>'
                                                    CommandArgument='<%#Eval("FileURL") %>'></asp:LinkButton>
                                            </ItemTemplate>
                                            <ItemStyle CssClass="text-left" />
                                        </asp:TemplateField>
                                    </Columns>
                                    <RowStyle CssClass="text-center" />
                                    <HeaderStyle CssClass="tblHeadNoWrap" />
                                </asp:GridView>
////////////////////////////////////// CS

protected void Lbtn_ViewPdf_Click(object sender, EventArgs e)
    {
        LinkButton l = sender as LinkButton;
        Session["AllFileSNamePath"] = l.CommandArgument.ToString();
        string url = "ViewTab";
        string script = string.Format("window.open('{0}');", url);
        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "newPage", script, true);
    }

                  




////////// New cs Page



protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TestPdf();
        }
    }
    private void TestPdf()
    {
        lblmsg.Text = "";
        string filenamae = Convert.ToString(Session["AllFileSNamePath"]);
        string path = Server.MapPath("~/Resources/" + filenamae);
        if (System.IO.File.Exists(path))
        {
            WebClient client = new WebClient();
            Byte[] buffer = client.DownloadData(path);
            if (buffer != null)
            {
                Response.ContentType = "application/pdf";
                Response.AddHeader("content-length", buffer.Length.ToString());
                Response.BinaryWrite(buffer);
            }
        }
        else
        {
            lblmsg.Text = "Selected file not found";
        }
    }
                               

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...