Sunday, 29 November 2015

Disable WeekEnds Using JQuery DateTimePicker Asp.Net

Disable WeekEnds Using JQuery DateTimePicker  

JQuery DatetimePicker Show WeekEnds Disable Before Showing Using Asp.Net .

                         DEMO


                    Download

                  HTML Coding

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Disable WeekEnds Using JQuery DateTimePicker Asp.Net</title>

    <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/ui-lightness/jquery-ui.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
      
   
    <script type="text/javascript" lang="javascript">
        $(function () {
            $("#<%=textboxDate.ClientID %>").datepicker({
                dateFormat: "dd/mm/yy",
                changeMonth:true,
                beforeShowDay: function (DATE) {
                    var Week = DATE.getDay();
                    if (Week == 0 || Week == 6)
                    {
                        return [false];
                    }
                    else
                    {
                        return [true];
                    }
                }
           
            });
        });
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
      
        <table><tr><td>
                        <asp:Label ID="Label1" runat="server" Text="Select Date"></asp:Label>
            </td><td>
                <asp:TextBox ID="textboxDate" runat="server"></asp:TextBox>
            </td></tr></table>
    </div>
    </form>
</body>

</html>






Monday, 16 November 2015

Ajax Updatepanel Image Upload with Triggers in Asp.Net C#

Ajax Updatepanel Image Upload with Triggers 


Ajax Update Panel Mainly Used to Avoid Whole Page Refresh With Trigger Function in Image Upload Controls 

UpdateMode="Conditional"

Two Child Tags   ContentTemplate and Triggers.

                               DEMO


                          Download 

                     HTML Coding 

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">

        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
           
               <table><tr><td></td><td></td></tr>
           <tr><td>Image</td><td><asp:FileUpload ID="FileUpload1" runat="server" /></td></tr>
           <tr><td></td><td>
               <asp:Button ID="btn_Upload" runat="server" OnClick="btn_Upload_Click" Text="Upload" />
               </td></tr>
       </table>
               
    </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger ControlID="btn_Upload" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>


                        C# Coding

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Data.SqlClient;
using System.Data;
using System.IO;

public partial class UpdatePanel : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btn_Upload_Click(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["dbcon"].ToString());
        con.Open();
        string imagename=FileUpload1.FileName;
        FileUpload1.SaveAs (Server.MapPath ("file/"+imagename));
        SqlCommand cmd = new SqlCommand("insert into register(imgname,imgpath)values('"+imagename+"','"+"file/"+imagename+"')",con);
        cmd.ExecuteNonQuery();
        Response.Write("<script>alert('Image Uploaded')</script>");

    }

}









Saturday, 14 November 2015

Simple Insert,Update,Delete Queries and Bind To Gridview,Dropdownlist Using VB.NET

Simple Insert,Update,Delete Queries and Bind To Gridview,Dropdownlist


Create Simple Insert,Update,Delete,Select Query and Bind To Gridview,Dropdownlist Using in VB.Net 

                                DEMO


                             Download

                         HTML Coding

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Simple Insert,Update,Delete Queries and Bind To Gridview,Dropdownlist Using VB.NET</title>   
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">         
        <table> 
            <tr><td>
        <asp:Label ID="Label1" runat="server" Text="Name"></asp:Label>
                </td><td>
        <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                </td><td></td></tr>
            <tr><td>
        <asp:Label ID="Label2" runat="server" Text="Number"></asp:Label>
                </td><td><asp:TextBox ID="txtNumber" runat="server"></asp:TextBox>
                </td><td></td></tr>
            <tr><td>Image</td><td>
        <asp:FileUpload ID="FileUpload1" runat="server" />
                </td><td></td></tr>
            <tr><td class="auto-style1"></td><td class="auto-style1">
        <asp:Button ID="Button1" runat="server" Text="Register" />
<asp:Button ID="Button2" runat="server" Text="Update" />
<asp:Button ID="Button3" runat="server" Text="Delete" />
<asp:Button ID="Button4" runat="server" Text="Select" />
   
                </td><td class="auto-style1"></td></tr>
            <tr><td>&nbsp;Username </td><td>
        <asp:DropDownList ID="DropDownList1" runat="server">
        </asp:DropDownList>
   
                </td><td></td></tr>
            <tr><td></td><td>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
            <Columns>
          <asp:ButtonField DataTextField="name" HeaderText="User Name" />
                <asp:ButtonField DataTextField="number" HeaderText="Number" Text="Button" />
                <asp:ImageField ControlStyle-Height="200" DataImageUrlField="imgpath" HeaderText="Image">
<ControlStyle Height="200px"></ControlStyle>
                </asp:ImageField>
            </Columns>
        </asp:GridView>
                </td></tr>
        </table> 

        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:dbcon %>" SelectCommand="SELECT * FROM [reg]"></asp:SqlDataSource>
       
</div>
    </form>
</body>

</html>

                             
                           C# Coding


Imports System.Data
Imports System.Data.SqlClient


Partial Class _Default
    Inherits System.Web.UI.Page

    Dim con As SqlConnection = New SqlConnection()
    ' Database Connection String
    Public Sub dbconn()
        con = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("dbcon").ConnectionString)
        con.Open()
    End Sub
    Protected Sub Page_Load(sender As Object, e As EventArgsHandles Me.Load
        BindDropDown()
    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgsHandles Button1.Click
        ' Insert Query with Image Upload
        dbconn()
        Dim imgname As String
        imgname = FileUpload1.FileName
        FileUpload1.SaveAs(Server.MapPath("file/" + imgname))

        Dim cmd As SqlCommand = New SqlCommand("insert into reg values('" + txtName.Text + "','" + txtNumber.Text + "','" + imgname + "','" + "file/" + imgname + "')", con)
        cmd.ExecuteNonQuery()
        Response.Write("<script>alert('Data Registered')</script>")
    End Sub

    Protected Sub Button2_Click(sender As Object, e As EventArgsHandles Button2.Click
        'Update query

        dbconn()
        Dim cmd As SqlCommand = New SqlCommand("update reg set number= '" + txtNumber.Text + "' where name='" + txtName.Text + "'", con)
        cmd.ExecuteNonQuery()
        Response.Write("<script>alert('Data Updated')</script>")

    End Sub

    Protected Sub Button3_Click(sender As Object, e As EventArgsHandles Button3.Click
        ' Delete Query
        dbconn()
        Dim cmd As SqlCommand = New SqlCommand("delete from reg where name='" + txtName.Text + "'", con)
        cmd.ExecuteNonQuery()
        Response.Write("<script>alert('Data Deleted')</script>")
    End Sub

    Protected Sub Button4_Click(sender As Object, e As EventArgsHandles Button4.Click
        ' reg table Bind To GridView
        dbconn()
        Dim cmd As SqlCommand = New SqlCommand("select * from reg", con)
        Dim adp As SqlDataAdapter = New SqlDataAdapter(cmd)
        Dim dt As DataTable = New DataTable()
        adp.Fill(dt)
        Dim rd As SqlDataReader = cmd.ExecuteReader()
        If (rd.Read()) Then
            GridView1.DataSource = dt
            GridView1.DataBind()
        Else
            GridView1.DataSource = ""
            GridView1.DataBind()
            Response.Write("<script>alert('No Records')</script>")
        End If

    End Sub
    Protected Sub BindDropDown()
        ' Name bind To Dropdownlist
        dbconn()
        Dim cmd As SqlCommand = New SqlCommand("select name from reg", con)
        Dim rd As SqlDataReader = cmd.ExecuteReader()
        While (rd.Read())
            DropDownList1.Items.Add(rd(0).ToString())
        End While

    End Sub

    Protected Sub GridView1_SelectedIndexChanged(sender As Object, e As EventArgsHandles GridView1.SelectedIndexChanged
    End Sub
End Class