<script type="text/javascript"> window.setInterval(DeleteKartItems, 10000); function DeleteKartItems() { PageMethods.DeleteItem(); alert("test"); } </script>
public static void DeleteItem() { string query = "[Get_Messages]"; SqlCommand cmd = new SqlCommand(query); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@roomId", 5); GetData(cmd); } private static void GetData(SqlCommand cmd) { string strConnString = ConfigurationManager.ConnectionStrings["LinqChatConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection(strConnString)) { using (SqlDataAdapter sda = new SqlDataAdapter()) { cmd.Connection = con; sda.SelectCommand = cmd; using (DataSet ds = new DataSet()) { sda.Fill(ds, "Messages"); } } } }
Page page = HttpContext.Current.Handler as Page; Label lblRoomId = (Label)page.FindControl("lblRoomId"); string lbRoomId = lblRoomId.Text;