2014 m. spalio 21 d., antradienis

2014 m. liepos 29 d., antradienis

JavaScript: console

Vietoje alert galima naudoti console.

if (window.console) console.log

IE - veikia su developer tools
Kitose naršyklėse veikia natūraliai

console:
- error
- log
- warn

2014 m. birželio 5 d., ketvirtadienis

Kaip įgyvendinti IComparer interfeisą su Visual Basic?

Problema: išrikiuoti Dictionary objektą.

Sprendimas:

1. Inicializuoti pradinius duomenis

        Dim Dictionary As New Dictionary(Of String, Integer)

        Dictionary.Add("A", 1)
        Dictionary.Add("B", 8)
        Dictionary.Add("C", 7)
        Dictionary.Add("D", 4)
        Dictionary.Add("E", 78)
        Dictionary.Add("F", 0)
        Dictionary.Add("G", 1)
        Dictionary.Add("H", 0)
        Dictionary.Add("I", 7)
        Dictionary.Add("J", 12)
        Dictionary.Add("K", 41)
        Dictionary.Add("L", 6)

2. Išrikiuoti

        Dictionary = SortDictionary(Dictionary)

3. Įgyvendinti SortDictionary funkciją

Private Function SortDictionary(ByVal dictionaryToSort As Dictionary(Of String, Integer)) As Dictionary(Of String, Integer)
        Dim SortList As List(Of KeyValuePair(Of String, Integer))
        SortList = dictionaryToSort.ToList
        dictionaryToSort.Clear()

        SortList.Sort(New DictionaryValueComparer)
        Return SortList.ToDictionary(Of String, Integer)(Function(keyPair As KeyValuePair(Of String, Integer)) keyPair.Key, Function(valuePair As KeyValuePair(Of String, Integer)) valuePair.Value)
    End Function

    Private Class DictionaryValueComparer
        Implements IComparer(Of KeyValuePair(Of String, Integer))
        Public Function Compare(ByVal x As System.Collections.Generic.KeyValuePair(Of String, Integer), ByVal y As System.Collections.Generic.KeyValuePair(Of String, Integer)) As Integer Implements System.Collections.Generic.IComparer(Of System.Collections.Generic.KeyValuePair(Of String, Integer)).Compare

            Dim num1 As Integer = x.Value
            Dim num2 As Integer = y.Value

            If num1 < num2 Then
                Return 1
            End If
            If num1 > num2 Then
                Return -1
            End If

            Return 0
        End Function
    End Class


Rezultatai:



http://stackoverflow.com/questions/2671236/sorting-a-dictionary-by-value - išrikiuoja skaičius
http://www.daniweb.com/software-development/vbnet/code/361733/sort-a-dictionary - išrikiuoja String eilutes

2014 m. gegužės 22 d., ketvirtadienis

MS SQL Database Read Only, Read/Write

Make Database Read Only

USE [master]
GO
ALTER DATABASE [TESTDB] SET READ_ONLY WITH NO_WAIT
GO

Make Database Read/Write


USE [master]
GO
ALTER DATABASE [TESTDB] SET READ_WRITE WITH NO_WAIT
GO

2014 m. balandžio 30 d., trečiadienis

70-480:Įvairūs klausimai

createObjectURL - iš File API

createObjectURL - eksperimentinė technologija, kai iš nuorodos į failą sukuriamas objektas.

objectURL = URL.createObjectURL(blob);
blob- Is a File object or a Blob object to create a object URL for.


Objektas gali būti "atlaisvintas" objectURL.revokeObjectURL.


XMLHttpRequest atsakymui iš serverio naudoja response, responseText, responseXML.
response - paima atsakymo duomenis
responseText - paima atsakymo duomenis kaip tekstą
responseXML - paima atsakymo duomenis kaip XML

HTML5 atributai



onblur - atsitinka, kai naudotojas nuima focus (lose focus);
onfocus - atsitinka, kai naudotojas uždeda focus (HTML).

onfocus priešingas onblur

onreset - įvyksta, kai paspaudžiamas reset mygtukas (HTML);
onselect - įvyksta, kai kas nors būna pažymėta input elemente (HTML).

Position static vs. absolute

position: static|absolute|fixed|relative|initial|inherit;

Pagal nutylėjimą - static.

2014 m. balandžio 28 d., pirmadienis

HTML5, CSS3, SVG: Darbui ir mokymuisi

CSS 3 su pavyzdžiais: http://ie.microsoft.com/testdrive/Graphics/hands-on-css3/

Kadangi HTML5, CSS3 ir SVG naujos ir vis tobulinamos, kuriamos technologijos, tai įvairių modulių "paruošimas" skiriasi. Galima pažiūrėti, kokiose naršyklėse naudojamos naujos HTML5, CSS3, SVG savybės: http://caniuse.com

http://www.html5rocks.com/en/ 
http://html5.validator.nu/

2014 m. balandžio 18 d., penktadienis

Visual Basic: Round su MidpointRounding.AwayFromZero

Decimal.Round((CDec(SkaiciusDecimal)), 0, MidpointRounding.AwayFromZero)

2014 m. balandžio 17 d., ketvirtadienis

MS SQL: DATEDIFF

Pvz., skaičiuoti dienoms

select DATEDIFF (DAY,'20130701','20140430')

2014 m. balandžio 7 d., pirmadienis

JavaScript: how to read var from URL

 function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        }

var dm = getUrlVars()["GID"];

2014 m. kovo 12 d., trečiadienis

MS SQL: ciklas, palengvinantis atnaujinimą

declare @lastint integer = 44
declare @currint integer = 12

WHILE (@currint<@lastint)
BEGIN

UPDATE [SERVERIS].DuomenuBaze.dbo.EIF_questions
SET QLTText=(SELECT QLTText FROM EIF_questions where ID=@currint)
WHERE ID=@currint;

SET @currint = @currint + 1

END


Atnaujinti dalį duomenų 


insert into [SERVERIS].DuomenuBaze.dbo.EIF_questions(ID, Col1, Col2, Col3)(select ID, Col1, Col2, Col3 from dbo.EIF_questions where ID>43)

2014 m. kovo 6 d., ketvirtadienis

Blog, wiki, URL

Blog - weblog sutrumpinimas, online dienoraštis arba log'as
wiki - What I Know Is

URL - Uniform Resource Locator (dar žinomas kaip web address)

VB Page_Load įvykio vykdymas

 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load

End Sub


Du kartus naudojamas MyBase.Load, Me. Load rodo, kad Page_Load įvykis bus vykdomas du kartus.

2014 m. sausio 26 d., sekmadienis

JQuery: kaip iškviesti WebService metodą sinchroniškai ir nusiųsti parametrus JSON formatu?

 $.ajax({
                             type: "POST",
                             url: sServiceURL + "/reorderRecord",
                             async: false,
                             data: '{ ordNew:' + JSON.stringify(reOrd) + '}',
                             contentType: "application/json; charset=utf-8",
                             dataType: "json",
                             success: function (msg) {
                                 alert("duomenys perduoti sekmingai");
                             },
                             error: function (xr) {
                                 alert(xr.responseText);
                             }
  });

2014 m. sausio 22 d., trečiadienis

GridView: RowUpdating



 Protected Sub gvMainGroups_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles gvMainGroups.RowUpdating

        Dim iID As Integer = e.Keys(0)

        Dim oGridRow = gvMainGroups.Rows(gvMainGroups.EditIndex)

        Dim srtOrd As TextBox = oGridRow.FindControl("tbSortOrder")

        Dim obj = (From mg In odb.MainGroups Where mg.Id = iID).First

        obj.ProductGroup = e.NewValues("ProductGroup").ToString.Trim
        obj.SortOrder = If(srtOrd.Text.Trim <> "", CInt(srtOrd.Text.Trim), CInt(1))

        odb.SubmitChanges()

        gvMainGroups.EditIndex = -1
        bind()
    End Sub



2014 m. sausio 21 d., antradienis

JQuery: kaip iškviesti webService metodą sinchroniškai?

 window.onbeforeunload = function () {

            var val = false;

            $.ajax({
                type: "POST",
                url: sServiceURL + "/checkRecordsStatus",
                async: false,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function (msg) {
                 
                    if (msg.d == true) {
                        val = true;
                    };

                }

            });

            if (val == true) {
                return 'Turite neišsaugotų testavimo įrašų!';
            }

        };

Protected Sub Page_PreRender(sender As Object, e As EventArgs) Handles Me.PreRender

        ScriptManager.RegisterStartupScript(Me, Me.GetType, "Service", "sServiceURL='" & VirtualPathUtility.ToAbsolute("~/ServicesPath.asmx") & "';", True)

    End Sub

JQuery: unload event, JavaScript: onbeforeunload event

Problema: pagauti įvykį, kad su window.open atidarytas langas uždaromas ne mygtuko paspaudimu, o pasirinkus dešiniajame viršutiniame kampe esantį mygtuką.

Sprendimas: naudoti unload event - lango užsarymo metu

 $(window).unload(function () {
            alert("Handler for .unload() called.");
        });



Arba naudoti onbeforeunload, prieš uždarant langą:

window.onbeforeunload = function () {
            return 'You have unsaved changes!';
        }

http://api.jquery.com/unload/ - JQuery įvykis

http://help.dottoro.com/ljhtbtum.php - onbeforeunload IE įvykis



http://help.dottoro.com/ljfvvdnm.php - visi įvykiai

2014 m. sausio 14 d., antradienis

ChartImageHandler in web.config

Dirbant su diagramomis, web.confige galima nurodyti, kur saugoti suformuotas diagramas. Jas galima saugoti:

atmintyje arba sesijoje 

< add key=" ChartImageHandler " value = " Storage = memory " / >

faile į nurodytą direktoriją

<appSettings>
    <add key="ChartImageHandler" value="Storage=file;Timeout=20;Url=~/rprts/tempImages/;deleteAfterServicing=true;webDevServerUseConfigSettings=false" />

</appSettings>

2014 m. sausio 9 d., ketvirtadienis

Entities and LIKE

Problema:
 
LINQ to Entities does not recognize the method 'Boolean Like(System.String, System.String)' method, and this method cannot be translated into a store expression.
 
   objs = From no In odbef.IKSA19_OrdNo_ProdCode
          Where Not no.IKSA19_Records.Any()
          Select no
          Distinct
 
   If tbOrderNo.Text.Trim <> "" Then
 
       objs = objs.Where(Function(x) Data.Linq.SqlClient.SqlMethods.Like(x.OrderNo, tbOrderNo.Text.Trim & "%"))
 
   End If
 
 
 
 
Sprendimas: naudoti contains
 
 
If tbOrderNo.Text.Trim <> "" Then
   objs = objs.Where(Function(x) x.OrderNo.Contains(tbOrderNo.Text.Trim))
End If
 
 
 

2014 m. sausio 8 d., trečiadienis

Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.

Problema:
 
·         CompilerServices.DesignerGenerated()> _
·         "font-size:9.16667px"><WebService(Namespace:="http://autogalleries.ca/")> _
·         =WsiProfiles.BasicProfile1_1)> _
·         ScriptService()> _
·         When I try to compile, it gives me the error: 
Error 1
Attribute specifier is not a complete statement. Use a line continuation to apply the attribute to the following statement.
 
 
Sprendimas:
 
_ turi būti dedamas vienu tarpu nuo eilutėje esančio teksto, pvz.,:
 
BLOGAI: CompilerServices.DesignerGenerated()>
GERAI: CompilerServices.DesignerGenerated()> _
 
 
Line continuation character '_' must be preceded by at least one white space and must be the last character on the line.