Έχω στο default.aspx έναν PlaceHolder που καλεί το ascx mod_search:
<form name="searchform" runat="server">
</asp:TextBox id="key" runat="server" Width="120px">
</asp:Button id="btn_search" runat="server" Text="go »" CssClass="mod_search">
</form>
το οποίο τρέχοντας θα καλέσει το search.ascx με κώδικα:
<script language="JavaScript">
<!--
function calcHeight()
{
//find the height of the internal page
var the_height=
document.getElementById('the_iframe').contentWindow.
document.body.scrollHeight;
//change the height of the iframe
document.getElementById('the_iframe').height=
the_height;
}
//-->
</script>
<%
dim url as string
'url="search.aspx?catid="+request("catid")+"&sub_cat="+request("sub_cat")+"&ssub_cat="+request("ssub_cat")+"&sssub_cat="+request("sssub_cat")
url="search.aspx?key="+request("key")
%>
</iframe id="the_iframe" marginWidth="0" marginHeight="0" src="<%Response.write(url) %>" frameBorder="no" width="400" onload="calcHeight();" height="600" style="WIDTH: 360px;">
Εδώ γίνεται η κλήση μέσα από iframe στο search.aspx που περιέχει
Imports System.Data.SqlClient
Public Class search1
Inherits System.Web.UI.Page
Private reader As SqlDataReader
Private adapter As Data.SqlClient.SqlDataAdapter
Private ds As DataTable
Private conn As SqlConnection
Private constr As String
Public func As functions
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
DGproducts.Columns(0).HeaderText = Session("TXT_search_results")
End Sub
Protected WithEvents DGproducts As System.Web.UI.WebControls.DataGrid
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Request("key") = "" Then
Return
End If
func = New functions
BindGrid()
End Sub
Function CreateDataSource() As ICollection
constr = ConfigurationSettings.AppSettings("ConnectionString")
conn = New SqlConnection(constr)
func = New functions
Dim key = Request("key") + ""
Try
'Dim strcmd As String = "SELECT * FROM db_content "
Dim strcmd As String = "SELECT * FROM db_content where title like '%" + func.convertFCKstring(key) + "%' or text like '%" + func.convertFCKstring(key) + "%' or smalltext like '%" + func.convertFCKstring(key) + "%' "
'Dim strcmd As String = "SELECT * FROM db_content where UPPER(title) like '%UPPER(" + func.convertFCKstring(key) + ")%' or UPPER(text) like '%UPPER(" + func.convertFCKstring(key) + ")%' or UPPER(smalltext) like '%UPPER(" + func.convertFCKstring(key) + ")%' "
'Dim cmd As SqlCommand = New SqlCommand(strcmd, conn)
'Response.Write(strcmd)
ds = New DataTable
adapter = New Data.SqlClient.SqlDataAdapter(strcmd, conn)
adapter.Fill(ds)
Me.DGproducts.DataSource = ds
DGproducts.DataBind()
CreateDataSource = New DataView(ds)
Catch ex As Exception
Response.Write("Error Search: " + ex.ToString)
End Try
End Function
Sub MyDataGrid_Page(ByVal sender As Object, ByVal e As DataGridPageChangedEventArgs)
DGproducts.CurrentPageIndex = e.NewPageIndex
BindGrid()
End Sub
Sub BindGrid()
DGproducts.DataSource = CreateDataSource()
DGproducts.DataBind()
End Sub
End Class
Το οποίο δεν πιστεύω να παίζει κάποιο ρόλο.
Το ενδιαφέρον είναι αυτό που παρατηρώ από τη δοκιμή σε IE & FF είναι ότι στον 2ο παίζει κανονικά (όταν γράψω ένα κριτήριο και πατήσω το κουμπί για την αναζήτηση φορτώνει αμέσως τα αποτελέσματα - στον IE πατώ το κουμπί μια φορά και δεν φορτώνει η ίδια σελίδα, ενώ με ένα κλικ ακόμα τότε έρχονται τα αποτελέσματα. Γενικότερα παρατήρησα ότι με κάθε submit υποβάλλονται τα δεδομένα ενός search πίσω.)
Το ωραίο είναι ότι δεν αλλάζει το περιεχόμενο της σελίδας στο πρώτο κλικ αλλά από το δεύτερο και πέρα με 1 εμφάνιση σελίδας καθυστέρηση κάθε φορά!
Εδώ έχω μπερδευτεί πάρα πολύ