<script type="text/javascript">
var
flag = true;
window.onload = function() {
document.getElementById("hdnPg").value = 1;
// for restart paging
from 1
var
TargetBaseControl = document.getElementById("TdContainer");
var
Inputs = TargetBaseControl.getElementsByTagName("input");
for
(var n = 0; n < Inputs.length; ++n) {
if
(Inputs[n].type == 'checkbox') {
Inputs[n].disabled = false;
Inputs[n].parentElement.disabled = false;
Inputs[n].checked = false;
Inputs[n].removeAttribute("checked");
}
}
}
function
AppendResult() {
//debugger;
var
getKey = document.getElementById("lblSearch").getElementsByTagName("u")
var
Key = getKey[0].innerHTML;
var
currPage = parseInt((document.getElementById("hdnPg").value))
+ 1;
var
KeyID = document.getElementById("hdnSearchUID").value;
var
ResultItem = searching.AppendProduct(Key, KeyID, currPage);
if
(ResultItem.value != "" &&
ResultItem != null && ResultItem.value
!= "N") {
document.getElementById("TdContainer").innerHTML +=
ResultItem.value;
document.getElementById("hdnPg").value =
parseInt((document.getElementById("hdnPg").value))
+ 1;
document.getElementById("pPage" + document.getElementById("hdnPg").value).innerHTML = "Page : " + document.getElementById("hdnPg").value;
}
if
(ResultItem.value == "N") {
document.getElementById("TdLoadMore").innerHTML = "No More Products For This Keyword";
document.getElementById("TdLoadMore").style.display = "block";
document.getElementById("divLoadingMessage").style.display = "none";
window.onscroll = null;
}
flag = true;
}
window.onscroll = function() {
var
tblCmp = document.getElementById("tblComparelist");
if
(document.documentElement.scrollTop != undefined) {
if
(document.documentElement.scrollTop > 175 || document.body.scrollTop >
175) {
tblCmp.style.top = 0;
tblCmp.style.position = "fixed";
tblCmp.style.width = 765 + "px";
}
else
{
tblCmp.style.position = "relative";
tblCmp.style.width = "100%";
}
}
else
if (window.pageYOffset != undefined) {
if
(window.pageYOffset > 175) {
tblCmp.style.top = 0;
tblCmp.style.position = "fixed";
tblCmp.style.width = 765 + "px";
}
else
{
tblCmp.style.position = "relative";
tblCmp.style.width = "100%";
}
}
else
{
tblCmp.style.position = "relative";
tblCmp.style.width = "100%";
}
/*For
scroll paging work fine in ie 7+ , mozilla, chrome*/
if
(navigator.appName == "Microsoft Internet
Explorer") {
if
(document.documentElement.scrollTop > document.documentElement.scrollHeight
- 660 && flag == true) {
document.getElementById("divLoading").style.display = "";
flag = false;
AppendResult();
document.getElementById("divLoading").style.display = "none";
}
}
else
{
if
(document.documentElement.scrollTop > window.scrollMaxY - 50 && flag
== true) {
document.getElementById("divLoading").style.display = "";
flag = false;
AppendResult();
document.getElementById("divLoading").style.display = "none";
}
else
if (document.body.scrollTop >=
(document.documentElement.scrollHeight - document.documentElement.clientHeight
- 20) && flag == true) {
document.getElementById("divLoading").style.display = "";
flag = false;
AppendResult();
document.getElementById("divLoading").style.display = "none";
}
}
}
function
AddToWishlist(obj) {
var
position = [0, 0];
var
DL = document.getElementById('<%=
"dlSearch"%>')
var
tblWish = document.getElementById("tblWishList");
if
(DL.offsetParent) {
do
{
position[0] +=
DL.offsetLeft;
position[1] +=
DL.offsetTop;
} while
(DL = DL.offsetParent);
}
var
result =
searching.AddToWishList(obj.parentElement.parentElement.parentElement.getElementsByTagName("input")[0].parentElement.title);
if
(result.value == "True") {
document.getElementById("cartCnt").innerHTML =
parseInt(document.getElementById("cartCnt").innerHTML)
+ 1;
tblWish.style.top = position[1]
+ "px";
tblWish.style.left = position[0] +
document.getElementById('<%=
"dlSearch"%>').offsetWidth + "px";
tblWish.style.position = "fixed";
tblWish.style.display = "block";
}
return
false;
}
function
ClearWishList() {
var
result = searching.ClearWishList();
var
tblWish = document.getElementById("tblWishList").style.display
= "none";
document.getElementById("cartCnt").innerHTML = 0;
}
script>
2) Add Code Behind AJAX Method:
Public Function AppendProduct(ByVal
key As String, ByVal KeyID As String, ByVal
CurrPage As String)
As String
Dim str
As String
Dim cn As New
SqlConnection(ConfigurationManager.AppSettings("ConnectionString"))
Dim da As SqlDataAdapter
If
cn.State = ConnectionState.Closed Then
cn.Open()
End If
' hdnPg.Value
= (Convert.ToInt32(hdnPg.Value) + 1).ToString()
Try
da = New
SqlDataAdapter("Usp_Searching",
cn)
da.SelectCommand.CommandType =
CommandType.StoredProcedure
da.SelectCommand.Parameters.AddWithValue("@CmdType",
"Select")
da.SelectCommand.Parameters.AddWithValue("@Mode", "Select_Product")
da.SelectCommand.Parameters.AddWithValue("@Keyword",
key)
'
da.SelectCommand.Parameters.AddWithValue("@KeyUID", KeyID)
da.SelectCommand.Parameters.AddWithValue("@intCurrIndex",
CurrPage)
da.SelectCommand.Parameters.AddWithValue("@intPageSize",
"12")
da.Fill(ds)
Dim
j As Integer =
0
If
(ds.Tables(0).Rows.Count > 0) Then
str = "
For
i1 As Integer =
0 To Math.Ceiling(ds.Tables(0).Rows.Count / 4)
- 1
str += "
"
For
i As Integer =
0 To 3
If ds.Tables(0).Rows.Count > (i + j) Then
str += "
"
End If
Next
j = j + 4
str += "
"
Next
str += "
"
str += "
"
If Not Session("CompareProductList") Is Nothing Then
If CType(Session("CompareProductList"),
Data.DataTable).Rows.Count >= 3 Then
str += "
"
Else
str += "
"
End If
Else
str += "
"
End If
str += "
"
str += "
"
str += "
"
str += "
str += "
|
Return
str
Else
Return
"N"
End
If
Return
""
End Try
End Function
No comments:
Post a Comment