Contact Me

Nirav Prabtani

Mobile : +91 738 308 2188

Email : niravjprabtani@gmail.com

Nirav Prabtani

Wednesday 13 September 2017

Data Access Layer

  SqlConnection cn = null;
        SqlCommand cmd = null;
        SqlDataAdapter da = null;

        public void OpenConnection(string SP_Name)
        {

            cn = new SqlConnection(ConfigurationManager.ConnectionStrings["DataListConnection"].ConnectionString);
            cmd = new SqlCommand(SP_Name, cn);
            cn.Open();
        }

        public DataTable GetDataTable(string SP_Name,Hashtable Data) {

            DataTable dt = new DataTable();
            OpenConnection(SP_Name);
            cmd.CommandType = CommandType.StoredProcedure;

            da = new SqlDataAdapter(cmd);

            foreach(string Datas in Data.Keys){

                cmd.Parameters.AddWithValue(Datas, Data[Datas]);
           
           
            }

            da.Fill(dt);
            CloseConnection();
            return dt;
       
        }


        public void CloseConnection() {

            cn.Close();
            cn.Dispose();
            cmd.Dispose();
       
        }



------------------------------------------------------------------------------------------------------------
table design


 $.ajax({
                type: "POST",
                url: "ta.aspx/BindData",
                contentType: "application/json",
                data: {},
                success: function (data) {

                    alert(data.d.length);

                    if (data.d.length > 0) {
                       
                        var Datas = "";

                        Datas += " ";

                        for (var i = 0; i < data.d.length; i++) {

                            if (i % 4 == 0) {

                                Datas += "
";                                Datas += " ";

                            }

                            Datas += "";

                            Datas += "
" + data.d[i].NAME + "" + data.d[i].MOBILE + "
";

                            Datas += "
";                         

                            alert(i%4);
                           
                             
                           


                        }
                        Datas += "
";

                        $("#data").empty();
                        $("#data").append(Datas);

                    }

                },
                error: function () {
                }
            });

Wednesday 16 July 2014

apply style to div like bubble chat

Apply style to div like bubble chat



try this.. Smile | :) 
 
.bubble 
{
position: relative;
width: 250px;
height: 120px;
padding: 0px;
background: #000000;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
}
 
.bubble:after 
{
content: "";
position: absolute;
top: -33px;
left: 182px;
border-style: solid;
border-width: 0 15px 33px;
border-color: #000000 transparent;
display: block;
width: 0;
z-index: 1;
}
 
 
<div class="bubble "></div>

How to show loading is in progress with the image using ajax


How to show loading is in progress with the image using ajax


 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
 
 
  .divBackMain
        {
            z-index: 99;
            position: fixed;
            top: 0px;
            left: 0px;
            height: 100%;
            width: 100%;
            background-color: black;
            opacity: 0.4;
        }
        .divLoader
        {
            position: fixed;
            top: 50%;
            left: 50%;
            z-index: 100;
            margin-left: -110px;
            margin-top: -110px;
            width: 220px;
            background-image: url('https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpPzVHnlXNXTc6jq2Po0M1-nmItU5hfQpTRgjwZN68pff20m-bYPgCx0Zt8PDWfMIjYKMvxPlTQPkmKKM8Qku4txlbbU1K_19mKVx6_VvdYL85-S5hl-xHfJgMshdgd4HVMF9x67D56hI/s1600/LoadingGIF.gif');
        }
        #DivLoaderContainer
        {
            display:none;
            }
 function UploadData() {
 
            $("#DivLoaderContainer").fadeIn(); //set fadeIn whenever ypu want to show loader
            $.ajax({
                type: "POST",
                url: "PageName.aspx/MethodName",
                contentType: "application/json;charset=utf-8",
                data: {}, //Parameters
                dataType: "json",
                success: function (data) {
 
                    $("#DivLoaderContainer").fadeOut(); //set logout after finish all process 

 
                },
                error: function (result) {
 

 
                }
            });
 
 <div id="DivLoaderContainer">
            <div class="divBackMain">
            </div>
            <div class="divLoader">
                <img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgpPzVHnlXNXTc6jq2Po0M1-nmItU5hfQpTRgjwZN68pff20m-bYPgCx0Zt8PDWfMIjYKMvxPlTQPkmKKM8Qku4txlbbU1K_19mKVx6_VvdYL85-S5hl-xHfJgMshdgd4HVMF9x67D56hI/s1600/LoadingGIF.gif" />
            </div>
        </div>

I have set visible using $("#DivLoaderContainer").fadeIn(); before ajax call
and after completion of ajax call it should be disappear using $("#DivLoaderContainer").fadeOut();
you can set fadeIn and fadeOut as per your need.. :)

How Do I Automatically Get Pc Name In Connection String


How Do I Automatically Get Pc Name In Connection String


try this.. Smile | :) 
 
System.Net.Dns.GetHostName();

or
System.Environment.GetEnvironmentVariable("COMPUTERNAME");
 
gives you current pc name.. Smile | :) 
 

 SqlConnectionStringBuilder connectionString = new SqlConnectionStringBuilder();
     connectionString.DataSource = System.Net.Dns.GetHostName();
     connectionString.InitialCatalog = "MyDatabase";
     connectionString.IntegratedSecurity = true;
    

How to automatically resize iframe from inside the iframe?


How to automatically resize iframe from inside the iframe?


Call that function of parent page from child page like that,
if you have function having name ReSize for resize iframe in parent page than you can call it from child page with top clause in javascript like that
 
Parent page function
 
function ReSize()
{
 
//Do stuff for iframe resize

} 
 

Child page function.
 
$(document).ready(function(){
 
top.ReSize(); //it will call main parent page function from child page.

});

There is no row at position 1


how to Solve " There is no row at position 1. "



your datatable doesn't contains any Rows in it, thats why that error occurs,
to prevent it always use condition to check like that
if(dt.Rows.Count>0)
{
//Do youe Stuff
}
 
1) Debug your code
2) Check is there any rows in your table DBCUSTOMERMASTER

how to apply text box value to label using javascript?


how to apply text box value to label using javascript?


try onkeypress event of textbox.. Smile | :) 
 
function settext(valueData)
{
  
    document.getElementById('<%=Label6.ClientID%>').innerHTML = valueData;
}
 
HTML
 
<asp:textbox id="txtbox1" runat="server" onkeypress="settext(this.value)" >
</asp:textbox>