Informacija apie WEB technologijas: ASP.NET, C#, PHP, ASP, CSS, JavaScript, JQuery, SEO.
2012 m. rugpjūčio 30 d., ketvirtadienis
LINQ: multiple OrderBy
Jeigu su Select išsitraukiame tik vieną parametrą, tada išrenkame unikalius (distinct)ir rūšiuojame paprastai su Order By:
Dim parts = (From p In odb.Parts Select p.Part Order By Part Ascending).Distinct.ToList
Jeigu su Select išritraukiame daugiau parametrų, tada rišrenkame unikalius (distinct)ir rūšiuojame pagal kelis iš jų, tai naudojame OrderBy, ThenBy:
Dim qResult = (From x In otrainee
Select x.em.NameFirst, x.em.NameLast, x.em.Id).Distinct.OrderBy(Function(x) x.NameLast).ThenBy(Function(x) x.NameFirst).ToList
Pastaba: OrderBy ir ThenBy rūšiuose ASC tvarka, o DESC tvarka papildomai yra
OrderByDescending, ThenByDescending
Užkrauti duomenis į JQuery pluginą DataTables
Error: Unable to get value of the property 'aoColumns': object is null or undefined
Solution: http://stackoverflow.com/questions/12023824/applying-a-jquery-datatable-plug-in-to-dynamically-generated-tables-from-asp-net
2012 m. rugpjūčio 28 d., antradienis
JQuery: didelės lentelės vaizdavimas
Problema: didelė lentelė, kai norima, kad pirmas stulpelis būtų fiksuotas.
Sprendimas:
http://www.datatables.net/extras/fixedcolumns/
Pritaikant šią biblioteką svarbu, kad lentelės sutruktūra būtų būtent tokia, kokios reikalaujama http://www.datatables.net/usage/. Tam reikės papildomai į VB ASP.NET įdėti kodą, kuris nurodo, kur DataGrid'e bus headeris
< asp:DataGrid GridLines="Both" ID="dgTrainingMatrix1" runat="server" AutoGenerateColumns="true"
UseAccessibleHeader="True"
< / asp:DataGrid >
Protected Sub dgTrainingMatrix_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgTrainingMatrix.PreRender
If dgTrainingMatrix.Rows.Count > 0 Then
dgTrainingMatrix.HeaderRow.TableSection = TableRowSection.TableHeader
End If
End Sub
Protected Sub dgTrainingMatrix_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles dgTrainingMatrix.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
For i = 1 To (e.Row.Cells.Count - 1)
e.Row.Cells(i).Text = Server.HtmlDecode(e.Row.Cells(i).Text)
Next
End If
End Sub
Dim objDataTable As New System.Data.DataTable
objDataTable.Columns.Add(GetString(372), String.Empty.GetType())
For Each oc In oCources
Dim trCol As DataColumn = objDataTable.Columns.Add(oc.TrDTitle, String.Empty.GetType())
Next
For Each empl In oEmpl
Dim strList1 = New List(Of String)
strList1.Add(empl.NameLast & " " & empl.NameFirst)
For Each oc In oCources
Dim findCourse = False
For Each ot In otm
If (ot.tv.TrEmpID = empl.Id And ot.tv.TrDescID = oc.TrDID And findCourse <> True) Then
If ot.tv.TrIWILastTrainingIssueNo IsNot Nothing And ot.tv.TrIWIIssueNo IsNot Nothing And ot.tv.TrIWILastTrainingIssueNo > ot.tv.TrIWIIssueNo Then
strList1.Add("< img src='../ images/ TrainingMatrix/ matrix_update.gif' alt='' />")
ElseIf ot.tv.TrRefreshDate IsNot Nothing And ot.tv.TrRefresh IsNot Nothing Then
If (ot.tv.TrRefreshDate - Today.Date).Value.TotalDays < 0 Then
strList1.Add("< img src= '../ images/ TrainingMatrix/ matrix_update.gif' alt=' '/>")
Else
strList1.Add("< img src= '../images/ TrainingMatrix/ matrix_good.gif' alt=''/>")
End If
Else
strList1.Add("< img src='../ images/ TrainingMatrix/ matrix_good.gif' alt= '' />")
End If
findCourse = True
End If
Next
If findCourse <> True Then
strList1.Add("< img src='../ images / TrainingMatrix / matrix_bad.gif' alt = ' ' />")
End If
Next
objDataTable.Rows.Add(strList1.ToArray)
Next
If objDataTable.Columns.Count > 0 Then
Dim objDT As System.Data.DataTable = objDataTable
Me.dgTrainingMatrix.DataSource = objDT
Me.dgTrainingMatrix.DataBind()
End If
Galutinis rezultatas:
Sprendimas:
http://www.datatables.net/extras/fixedcolumns/
Pritaikant šią biblioteką svarbu, kad lentelės sutruktūra būtų būtent tokia, kokios reikalaujama http://www.datatables.net/usage/. Tam reikės papildomai į VB ASP.NET įdėti kodą, kuris nurodo, kur DataGrid'e bus headeris
< asp:DataGrid GridLines="Both" ID="dgTrainingMatrix1" runat="server" AutoGenerateColumns="true"
UseAccessibleHeader="True"
< / asp:DataGrid >
Protected Sub dgTrainingMatrix_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles dgTrainingMatrix.PreRender
If dgTrainingMatrix.Rows.Count > 0 Then
dgTrainingMatrix.HeaderRow.TableSection = TableRowSection.TableHeader
End If
End Sub
Kadangi lentelės celėse yra paveiksliukai, tai kad jie būtų intepretuojami kaip HTML kodas, o ne tekstas, papildomai reikia:
Protected Sub dgTrainingMatrix_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles dgTrainingMatrix.RowDataBound
If (e.Row.RowType = DataControlRowType.DataRow) Then
For i = 1 To (e.Row.Cells.Count - 1)
e.Row.Cells(i).Text = Server.HtmlDecode(e.Row.Cells(i).Text)
Next
End If
End Sub
DataGrid dinamiškai užpildomas taip:
Dim objDataTable As New System.Data.DataTable
objDataTable.Columns.Add(GetString(372), String.Empty.GetType())
For Each oc In oCources
Dim trCol As DataColumn = objDataTable.Columns.Add(oc.TrDTitle, String.Empty.GetType())
Next
For Each empl In oEmpl
Dim strList1 = New List(Of String)
strList1.Add(empl.NameLast & " " & empl.NameFirst)
For Each oc In oCources
Dim findCourse = False
For Each ot In otm
If (ot.tv.TrEmpID = empl.Id And ot.tv.TrDescID = oc.TrDID And findCourse <> True) Then
If ot.tv.TrIWILastTrainingIssueNo IsNot Nothing And ot.tv.TrIWIIssueNo IsNot Nothing And ot.tv.TrIWILastTrainingIssueNo > ot.tv.TrIWIIssueNo Then
strList1.Add("< img src='../ images/ TrainingMatrix/ matrix_update.gif' alt='' />")
ElseIf ot.tv.TrRefreshDate IsNot Nothing And ot.tv.TrRefresh IsNot Nothing Then
If (ot.tv.TrRefreshDate - Today.Date).Value.TotalDays < 0 Then
strList1.Add("< img src= '../ images/ TrainingMatrix/ matrix_update.gif' alt=' '/>")
Else
strList1.Add("< img src= '../images/ TrainingMatrix/ matrix_good.gif' alt=''/>")
End If
Else
strList1.Add("< img src='../ images/ TrainingMatrix/ matrix_good.gif' alt= '' />")
End If
findCourse = True
End If
Next
If findCourse <> True Then
strList1.Add("< img src='../ images / TrainingMatrix / matrix_bad.gif' alt = ' ' />")
End If
Next
objDataTable.Rows.Add(strList1.ToArray)
Next
If objDataTable.Columns.Count > 0 Then
Dim objDT As System.Data.DataTable = objDataTable
Me.dgTrainingMatrix.DataSource = objDT
Me.dgTrainingMatrix.DataBind()
End If
Galutinis rezultatas:
2012 m. rugpjūčio 23 d., ketvirtadienis
A error has TimThumb occured
Problem:
A error has TimThumb occured The Following error (s) occured: Could not open the LockFile for writing an image.
Solution:
I made the cache folder permissions to 777.
2012 m. rugpjūčio 21 d., antradienis
2012 m. rugpjūčio 19 d., sekmadienis
The server tag is not well formed.
Sprendimas:
<asp:HyperLink ID="lnkProject" Target="_blank" runat="server" Text='<%# Eval("PM_No")%>'
NavigateUrl='<%# "http://lelx/GIDC/Request.aspx?ID=" & Eval("PM_No") %>'></asp:HyperLink>
<asp:HyperLink ID="lnkProject" Target="_blank" runat="server" Text='<%# Eval("PM_No")%>'
NavigateUrl='<%# "http://lelx/GIDC/Request.aspx?ID=" & Eval("PM_No") %>'></asp:HyperLink>
2012 m. rugpjūčio 16 d., ketvirtadienis
Only Web services with a [ScriptService] attribute on the class definition can be called from script.
Sprendimas:
Į service.vb puslapį įdėti eilutę
< System . Web . Script . Services. ScriptService() > _
Į service.vb puslapį įdėti eilutę
< System . Web . Script . Services. ScriptService() > _
2012 m. rugpjūčio 15 d., trečiadienis
LINQ: Group Join example
Dim obj = From a In odb.Table1
Join pm In odb.Table2 On a.SysID Equals pm.PSystem_Dept
Group Join sgs In odb.Table3 On sgs.PM_No Equals pm.PM_No Into tms = Group
From t In tms.DefaultIfEmpty()
Where (a.SysID = ddlSystem.SelectedValue)
Select New With {
pm.PM_No,
pm.PM_Title,
pm.PM_Descr,
pm.CreatedOn,
pm.Done,
t.SGS,
t.SGS_Notes
}
Join pm In odb.Table2 On a.SysID Equals pm.PSystem_Dept
Group Join sgs In odb.Table3 On sgs.PM_No Equals pm.PM_No Into tms = Group
From t In tms.DefaultIfEmpty()
Where (a.SysID = ddlSystem.SelectedValue)
Select New With {
pm.PM_No,
pm.PM_Title,
pm.PM_Descr,
pm.CreatedOn,
pm.Done,
t.SGS,
t.SGS_Notes
}
2012 m. rugpjūčio 14 d., antradienis
2012 m. rugpjūčio 7 d., antradienis
ShowModalDialog and cache
Puslapiuose, kurie iškviečiami naudojant showModalDialog, kaip čia:
varsFeatures = "dialogWidth:880px;dialogHeight:600px;status:no;unadorned:yes;help:no;";
var oResult = window.showModalDialog("Test.aspx?GroupID=" + courseID, null, sFeatures);
Būtinai užkraunant Test.aspx puslapyje Page_Load įvykyje reikia eilutės:
Response.Cache.SetNoStore()
varsFeatures = "dialogWidth:880px;dialogHeight:600px;status:no;unadorned:yes;help:no;";
var oResult = window.showModalDialog("Test.aspx?GroupID=" + courseID, null, sFeatures);
Būtinai užkraunant Test.aspx puslapyje Page_Load įvykyje reikia eilutės:
Response.Cache.SetNoStore()
žymės:
ASP.NET,
Cache,
showModalDialog,
VB
2012 m. rugpjūčio 4 d., šeštadienis
MS SQL: serverių prilinkinimas
Prilinkinimui yra Server Objects - > Linked servers
žymės:
Linked servers,
MS SQL,
Server Objects
LINQ: join inner, join outer
inner join:
full outer join:
Pagal: http://stackoverflow.com/questions/38549/sql-difference-between-inner-and-outer-join
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim oTrain = From t In oDB.TrainingSelfs
Join c In oDB.TrainingCourses On c.CourseID Equals t.TrCourseID
Join cdesc In oDB.TrainingDescs On cdesc.TrDID Equals t.TrDescID
Group Join em In oDB.Employees On em.Id Equals t.TrRecBy Into tbtmp = Group
From em In tbtmp.DefaultIfEmpty
If lstSite.SelectedValue <> "" Then oTrain = oTrain.Where(Function(x) x.t.TrSite = lstSite.SelectedValue)
If lstTrainee.SelectedValue <> "" Then oTrain = oTrain.Where(Function(x) x.t.TrainingEmployeeSelfs.Any(Function(es) es.TrEmpID = lstTrainee.SelectedValue))
If lstTrainer.SelectedValue <> "" Then oTrain = oTrain.Where(Function(x) x.t.TrTrainerID = CInt(lstTrainer.SelectedValue))
If lstTrainerEnter.SelectedValue <> "" Then oTrain = oTrain.Where(Function(x) x.t.TrRecBy = CInt(lstTrainerEnter.SelectedValue))
Dim qResult = From x In oTrain Order By x.t.TrDate Descending
Select New TrainSlfView With {
.TrID = x.t.TrID,
.TrDate = x.t.TrDate,
.TrTrainerName =
If(x.t.TrTrainerID IsNot Nothing, If(oUser.ISEmpSite = "Lithuania", x.t.TrTrainerIDEmployee.NameLast & " " & x.t.TrTrainerIDEmployee.NameFirst, x.t.TrTrainerIDEmployee.NameFirst & " " & x.t.TrTrainerIDEmployee.NameLast), x.t.TrTrainerName),
.TrDuration = x.t.TrDuration,
.TrCost = x.t.TrCost,
.TrLocation = x.t.TrLocation,
.TrTitle = x.cdesc.TrDTitle,
.TrCourseTitle = x.c.CourseTitle,
.TrStatus = x.t.TrStatus,
.TrNotes = x.t.TrNotes
}
grdTrainingView.DataSource = qResult
grdTrainingView.DataBind()
End Sub
full outer join:
Pagal: http://stackoverflow.com/questions/38549/sql-difference-between-inner-and-outer-join
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim oTrain = From t In oDB.TrainingSelfs
Join c In oDB.TrainingCourses On c.CourseID Equals t.TrCourseID
Join cdesc In oDB.TrainingDescs On cdesc.TrDID Equals t.TrDescID
Group Join em In oDB.Employees On em.Id Equals t.TrRecBy Into tbtmp = Group
From em In tbtmp.DefaultIfEmpty
If lstSite.SelectedValue <> "" Then oTrain = oTrain.Where(Function(x) x.t.TrSite = lstSite.SelectedValue)
If lstTrainee.SelectedValue <> "" Then oTrain = oTrain.Where(Function(x) x.t.TrainingEmployeeSelfs.Any(Function(es) es.TrEmpID = lstTrainee.SelectedValue))
If lstTrainer.SelectedValue <> "" Then oTrain = oTrain.Where(Function(x) x.t.TrTrainerID = CInt(lstTrainer.SelectedValue))
If lstTrainerEnter.SelectedValue <> "" Then oTrain = oTrain.Where(Function(x) x.t.TrRecBy = CInt(lstTrainerEnter.SelectedValue))
Dim qResult = From x In oTrain Order By x.t.TrDate Descending
Select New TrainSlfView With {
.TrID = x.t.TrID,
.TrDate = x.t.TrDate,
.TrTrainerName =
If(x.t.TrTrainerID IsNot Nothing, If(oUser.ISEmpSite = "Lithuania", x.t.TrTrainerIDEmployee.NameLast & " " & x.t.TrTrainerIDEmployee.NameFirst, x.t.TrTrainerIDEmployee.NameFirst & " " & x.t.TrTrainerIDEmployee.NameLast), x.t.TrTrainerName),
.TrDuration = x.t.TrDuration,
.TrCost = x.t.TrCost,
.TrLocation = x.t.TrLocation,
.TrTitle = x.cdesc.TrDTitle,
.TrCourseTitle = x.c.CourseTitle,
.TrStatus = x.t.TrStatus,
.TrNotes = x.t.TrNotes
}
grdTrainingView.DataSource = qResult
grdTrainingView.DataBind()
End Sub
žymės:
inner join,
join outer,
LINQ,
where
Užsisakykite:
Pranešimai (Atom)