asp.net sayfalama

Asp.net ‘de datagridview kullandığımız zaman sayfalamayı .NET kendisi yapıyor ama listenizi kendiniz oluşturuyorsanız o zaman problemler çıkabiliyor.

Aşağıdaki metoda toplam sayfa sayısını,ekrandaki sayfayı ve gideceğimiz linkin ön ekini göndererek şu şekilde sayfalama oluşturabiliriz.sayfalama.gif

private static string sayfalamaYap(int ts, int es, string yol)

{//ts=toplam sayfa, es=ekrandaki sayfa, yol = link

    int eis = 0;

    int ess = 0;

    bool i2demi = (es – 6 < 1) ? true : false//ilk 2 sayfadan birindeysek true–not:-2 idi

    bool s2demi = (ts – 6 < es) ? true : false; //son 2 sayfadan birindeysek true

    bool imi = (es == 1) ? true : false;        //ilk sayfa isek true

    bool smu = (es == ts) ? true : false;      //son sayfa isek true

    string text = “<div id=\”paging\”>”;

    string buton = “<a href=\”/” + yol + “{0}\” class=\”{2}\”>{1}</a>”;

    if (i2demi & s2demi) { eis = 1; ess = ts; }

    else if (!i2demi & s2demi) { eis = ts – 8; ess = ts; }

    else if (i2demi & !s2demi) { eis = 1; ess = 8; }

    else { eis = es – 4; ess = es + 4; }

    if (!imi) { text += string.Format(buton, (es – 1).ToString(), “< previus”, “nav”); }

    if (!i2demi) { text += string.Format(buton, “1”, “1”, “nav”) + string.Format(buton, “2”, “2”, “nav”) + ” … “; }

    for (int i = eis; i <= ess; i++)

    {

        if (i == es) { text += “<span href=\”\” class=\”navnone\”>” + i.ToString() + “</span>”; }

        else { text += string.Format(buton, i.ToString(), i.ToString(), “nav”); }

    }

    if (!s2demi) { text += ” … “ + string.Format(buton, (ts – 1).ToString(), (ts – 1).ToString(), “nav”) + string.Format(buton, ts.ToString(), ts.ToString(), “nav”); }

    if (!smu) { text += string.Format(buton, (es + 1).ToString(), “next >”, “nav”); }

    return text + “</div>”;

}

 

“The project location is not fully trusted by the .NET runtime”


.NET projenizin bulunduğu konumla ilgili güvenlik sorunu olduğu zaman ekranınızda, “The project location is not fully trusted by the .NET runtime” uyarısı alırsınız çözümü;
Denetim masası > Yönetimsel Araçlar > .NET Configuration X.xx
(projenizin kullandığı framework versiyonuna göre) sonra

Runtime Security Policy > Machine > All Code > Add a Child Code Group a tıklayın.

Continue reading

Using C# & FFMPEG

Over the past 3 years, I’ve been searching extensively for a open-source (or low-cost) alternative for video conversion to the .flv format. This search typically leads directly to FFmpeg, an open source video compression and conversion tool. FFMPEG is umbelievably fast, and handles Flash Video without a problem. The biggest hurdle that I’ve run into when trying to design it into my applications is that it does not have a .NET interface and the open source libraries it uses are long and confusing. This week, however, I found a post on Daniel’s blog which contains a project that wraps the FFmpeglibraries. I haven’t gotten a chance to look at it too thoroughly, but it should definately open up the opportunity to make use of FFmpeg’s tools in a managed environment. Even if Daniel doesn’t take the project much further, it looks like a great start to a complete .NET FFmpeg library!

usefull links:
http://sourceforge.net/projects/sharpffmpeg
http://www.bytescout.com/ffmpegscout.html
http://www.iepak.com/2/TopicDetail.aspx