Thursday, November 29, 2012

Query Doesnot After PostBack



JQuery Doesnot After PostBack
and
FileUpload Content Refreshed During pageload if it is used in a user control

If your usercontrol has a file upload button and when you are inserting data or in any post back its refreshed then do one thing
Go to your user control page load event and put the following code there

  ScriptManager.GetCurrent(this.Parent.Page).RegisterPostBackControl(ImgBtnSave);

ImgBtnSave is the control where we are trying to add data without refreshing the file upload content.

THANKS Rehan Parvez

Friday, November 23, 2012

Dynamic Stored Procedure for Update

 

Create procedure [dbo].[sp_GenericUpdate]                  
   (  
    @tabName varchar(2000),
    @setCond varchar(2000),
    @whereCond nvarchar(2000)
    )          
As
declare @sql varchar(4000)
if @whereCond <>''
    begin
        select @sql = 'Update '+ @tabName +' Set ' + @setCond  +' Where ' + @whereCond
   
    end
else
    begin
        select @sql = 'Update '+ @tabName +' Set ' + @setCond
    end  
    exec (@sql)  
   

Dynamic Stored Procedure for Select

Dynamic Stored Procedure for Select Query
this Genic Stored Procedure for all Tables


USE [itechgal_lkms]
GO
/****** Object:  StoredProcedure [dbo].[sp_Generic]    Script Date: 11/24/2012 10:40:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
/*
Procedure Name : sp_Generic
Created by : Chiru
Created On : 22-10-2010
Modified By :  
Description :
               
*/
 
 
ALTER procedure [dbo].[sp_Generic]                  
   (
   
    @colName varchar(2000),
    @tableName varchar(2000),
    @whereCond varchar(2000)
    )
   
           
As

declare @sql varchar(4000)

if @whereCond <>''
    begin
        select @sql = 'select '+ @colName +' from ' + @tableName + ' Where ' + @whereCond
    end
else
    begin
        select @sql = 'select '+ @colName +' from ' + @tableName
    end
   
    exec (@sql)

Thursday, November 22, 2012

Change Style Of Checkboxes and Radio Buttons

Change Style Of Checkboxes and Radio Buttons using CSS
_________________________________________________________________________



CSS Code


/*
    Document   : style
    Created on : Aug 29, 2012, 3:59:32 PM
    Author     : Nick
    Description:
        Purpose of the stylesheet follows.
*/

html {
    height:100%;
}

body {
    position:relative;
    background:#f2f2f2;
    height:100%;
    padding:0;
    margin:0;
}

div#show {
    width:280px;
    height:200px;
    padding:20px;
    position:absolute;
    left:50%;
    margin-left:-120px;
    top:50%;
    margin-top:-160px;
    background:#40464b;
    border-radius:6px;
}

h1 {
    font-size:14px;
    color:#f2f2f2;
    text-align:center;
    margin:0 0 20px;
    padding:0;
    font-family:Arial;
}

input[type="checkbox"] {
    display:none;
}

input[type="checkbox"] + label {
    color:#f2f2f2;
    font-family:Arial, sans-serif;
    font-size:14px;
}

input[type="checkbox"] + label span {
    display:inline-block;
    width:19px;
    height:19px;
    margin:-1px 4px 0 0;
    vertical-align:middle;
    background:url(check_radio_sheet.png) left top no-repeat;
    cursor:pointer;
}

input[type="checkbox"]:checked + label span {
    background:url(check_radio_sheet.png) -25px top no-repeat;
}

input[type="radio"] {
    display:none;
}

input[type="radio"] + label {
    color:#f2f2f2;
    font-family:Arial, sans-serif;
    font-size:14px;
}

input[type="radio"] + label span {
    display:inline-block;
    width:19px;
    height:19px;
    margin:-1px 4px 0 0;
    vertical-align:middle;
    background:url(check_radio_sheet.png) -38px top no-repeat;
    cursor:pointer;
}

input[type="radio"]:checked + label span {
    background:url(check_radio_sheet.png) -57px top no-repeat;
}

______________________________________________________________________________
HTML BODY


<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="style.css" media="screen" />
    </head>
    <body>
        <div id="show">
            <h1>Easy CSS3 Checkboxes and Radio Buttons</h1>
            <input type="checkbox" id="c1" name="cc" />
            <label for="c1"><span></span>Check Box 1</label>
            <p>
            <input type="checkbox" id="c2" name="cc" />
            <label for="c2"><span></span>Check Box 2</label>
            <p><br/>
            <input type="radio" id="r1" name="rr" />
            <label for="r1"><span></span>Radio Button 1</label>
            <p>
            <input type="radio" id="r2" name="rr" />
            <label for="r2"><span></span>Radio Button 2</label>
        </div>
    </body>
</html>



Wednesday, November 21, 2012

Chat Application using Web services in C#


Build a Web Chat Application using ASP.Net 3.5, LINQ and AJAX (in C# 3.5 or VB 9.0)

 Code Download: Click here to download the code

Timer Clock Using JavaScript


     <script language="javascript" type="text/javascript">
          var tim;
          var min;
          var sec;
          var f = new Date();

          function f1() {
              min = parseInt(document.getElementById("hdnMin").value);
              sec = parseInt(document.getElementById("hdnSec").value);

              f2();
              //document.getElementById("starttime").innerHTML = "Your Exam started at " + f.getHours() + ":" + f.getMinutes();
              document.getElementById("starttime").innerHTML = "<img src='images/doble-quotes-01.gif' alt='' />Exam started at " + f.toLocaleTimeString() + "<img src='images/doble-quotes-02.gif' alt='' />&nbsp;";

              f1 = new Date(f);
              f1.setMinutes(f.getMinutes() + (parseInt(document.getElementById("hdnMin").value) + 1));

              //document.getElementById("endtime").innerHTML = "Your Exam end at " + f1.getHours() + ":" + f1.getMinutes();
              document.getElementById("endtime").innerHTML = "<img src='images/doble-quotes-01.gif' alt='' />Exam end at " + f1.toLocaleTimeString() + "<img src='images/doble-quotes-02.gif' alt='' />&nbsp;";
          }

          function f2() {
              if (parseInt(sec) > 0) {
                  sec = parseInt(sec) - 1;
                  document.getElementById("showtime").innerHTML = "<img src='images/doble-quotes-01.gif' alt='' />Time Left:" + min + " Minutes ," + sec + " Seconds <img src='images/doble-quotes-02.gif' alt='' />";
                  tim = setTimeout("f2()", 1000);
              }
              else {
                  if (parseInt(sec) == 0) {
                      if (parseInt(min) == 1) {
                          sec = parseInt(document.getElementById("hdnSec").value);
                      }
                      if (parseInt(min) > 0) {
                          min = parseInt(min) - 1;
                      }
                      else {
                          min = 0;
                      }
                      if (parseInt(min) == 0 && parseInt(sec) == 0) {
                          clearTimeout(tim);
                          location.href = "WebForm1.aspx";
                      }
                      else {
                          sec = parseInt(document.getElementById("hdnSec").value);
                          document.getElementById("showtime").innerHTML = "Time Left:" + min + " Minutes ," + sec + " Seconds";
                          tim = setTimeout("f2()", 1000);
                      }
                  }

              }
          }
    </script>

</head>

_________________________________________________________________________________
<body onload="javascript:f1();">

   <table cellpadding="0" cellspacing="0" border="0" width="1100px">
                                            <tr class="title">
                                                <td align="left">
                                                    <div id="starttime">
                                                    </div>
                                                </td>
                                                <td align="left">
                                                    <div id="endtime">
                                                    </div>
                                                </td>
                                                <td align="left">
                                                    <div id="showtime">
                                                    </div>
                                                </td>
                                                <td align="right" style="width: 270px; max-width: 270px">
                                                    <asp:Label ID="lblDisplayName" CssClass="title3" runat="server"></asp:Label>
                                                </td>
                                            </tr>
                                        </table>


</body>

Jquery Doenot Work After Post Back

Jquery Statement Doenot Work After Post Back this Problem Stake Me For Some Days


 $(function () {
       // alert("Simple");
       $('#show').click(function(){
        $('.divvv').toggle(slow);
                  });
    });



Some As Above But Add  Single Line and Bind Method in Particular Function and Function on Each PostBack


   Sys.WebForms.PageRequestManager.getInstance().add_endRequest(funtionPost);  

//calling on each posback

funcion funtionPost()
{

 $(function () {
       // alert("Simple");
       $('#show').click(function(){
        $('.divvv').toggle(slow);
                  });
    });
}


Tuesday, November 20, 2012

How to Unchecked RadioButton

use followin code RadioButton Unchecked Problem is not occur
work in both html or asp.net
same code for both


   $(document).ready(function () {
            $("input[type='radio']").mousedown(function (e) {
                if ($(this).attr("checked") == true) {
                    setTimeout("$('input[id=" + $(this).attr('id') + "]').removeAttr('checked');", 200);
                }
                else {
                    return true
                }
            });
        });

Rehan Parvez

Rehan Parvez