asp.net mvc etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
asp.net mvc etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

11 Eylül 2012 Salı

asp.net mvc de bot yapımı

sayfadaki tüm <a> ve <a> tagı içerisindeki <img> taglarını çekmek için
public ActionResult Index()
        {
            ViewData["datas"] = ss();
            return View();
        }
        List<string> dataList = new List<string>();
        private List<string> ss()
        {
            string Site = "http://shiftdelete.net/";
            WebClient client = new WebClient();
            Stream data = client.OpenRead(Site);
            StreamReader reader = new StreamReader(data, Encoding.GetEncoding("utf-8"));
            string datas = reader.ReadToEnd();

            string pattern3 = "<a.*?href=.*?>(.*?(<img.*?>).*?)</a>";
            MatchCollection mathcollection = System.Text.RegularExpressions.Regex.Matches(datas, pattern3);
            foreach (Match match in mathcollection)
            {
                if (match.Value.ToString().Contains("<img"))
                        dataList.Add(match.Value);
            }
            return dataList;
        }



//******************************************//
index sayfamız

<h2>Index</h2>
@{
    List<string> datas = (List<string>)ViewData["datas"];
    foreach(string s in datas.ToList())
    {
        <hr />
        <label>@s.ToString()</label>
    }
    }


9 Eylül 2012 Pazar

asp.net mvc de jQuery.ajax ile UserControl Kullanımı

function f_EditCategory(path) {
        $.ajax({
            url: path, type: 'POST',
            success: function (data) {
                $("#divTake").load(data);
            },
            data: { Mode: ID }
        });
        jQuery.facebox();
    } 

<a onclick='f_EditCategory("/AHome/EditCategory/5/"'>Kategori Düzenle </a>
<div id='divTake'></div>

//***************************************//

    [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult EditCategory(int? p1)
    {
        ViewData["ID"] = p1.HasValue ? p1.Value : 0;
        return PartialView("UserControl1");
    }

//**************************************//

UserControl1 içeriği
<div>
gelen ID @ViewData[ID]
</div>

8 Eylül 2012 Cumartesi

asp.net mvc de jQuery.ajax ile Resim,Dosya(multiupload) Ekleme

http://www.uploadify.com/ ilgili dosyaları indirdikten sonra

<link href="@Url.Content("~/Content/uploadify/uploadify.css")" rel="stylesheet" type="text/css" />

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>

<script src="@Url.Content("~/Content/uploadify/jquery.uploadify.min.js")" type="text/javascript"></script>

<script type="text/javascript">


    jQuery(document).ready(function () {

        var inputName = "file";

        jQuery("#" + inputName).uploadify({

            'hideButton': true,
            'wmode': 'transparent',
            'buttonText':'Seçiniz',
            'swf': '@Url.Content("~/Content/uploadify/uploadify.swf")',
            'uploader': '@Url.Action("Upload","Home")',
            'script': '@Url.Action("Upload", "Home")',
            //'script': '/Home/Upload',
            'fileDataName': inputName,
            'sizeLimit': 38000000,
            'cancelImg': '@Url.Content("~/Content/uploadify/cancel.png")',
            'auto': false,
            'debug': false,
            'multi': true,
            'formData': { 'ID': '2', 'KID': '3' },// Extra parametre göndermek isteyenler için..
            "onUploadStart":function (file) { $("#" + inputName).uploadify("settings", "ID", 'KID', 2); },// Extra parametre göndermek isteyenler için..

onError: function () { alert('some error occurred. Sorry'); },

            onComplete: function (event, queueId, fileObj, response, data) { alert(response); }
        });
    });
</script>

<p>
    <form method="post" enctype="multipart/form-data">
        <p>
            <input type="file" name="file" id="file" />
            <a href="javascript:$('#file').uploadify('upload','*')">Upload Files</a>
        </p>
    </form>
</p>


        [HttpPost]

        public JsonResult Upload(int? ID,int? KID)
        {
            foreach (string file1 in Request.Files)
            {
                var postedFileBase = Request.Files[file1];            
                string filename= postedFileBase.FileName;
                postedFileBase.SaveAs(HttpContext.Server.MapPath("/UserFiles/") + filename);

            }

            return Json(true);
        }



4 Eylül 2012 Salı

asp.net mvc de döviz kurlarını alma

public ActionResult Index()
        {
            
            XmlTextReader oku = new XmlTextReader("http://www.tcmb.gov.tr/kurlar/today.xml");
            XmlDocument dok = new XmlDocument();
            dok.Load(oku);
            XmlNode xdollar = dok.SelectSingleNode("/Tarih_Date/Currency[CurrencyName='US DOLLAR']");
            XmlNode xeuro = dok.SelectSingleNode("/Tarih_Date/Currency[CurrencyName='EURO']");
            XmlNode xsterling = dok.SelectSingleNode("/Tarih_Date/Currency[CurrencyName='POUND STERLING']");

            double dolar = double.Parse(xdollar.ChildNodes[4].InnerText);
            double euro = double.Parse(xeuro.ChildNodes[4].InnerText);
            double sterling = double.Parse(xsterling.ChildNodes[4].InnerText);
            
            ViewData["dolar"] = dolar;
            ViewData["euro"] = euro;
            ViewData["sterling"] = sterling;
         
             //ya da

            Func<XmlNode, double> fnc = delegate(XmlNode x) {
                  return double.Parse(x.ChildNodes[4].InnerText);
            };
            ViewData["dolar"] = fnc(xdollar);
            ViewData["euro"] = fnc(xeuro);
            ViewData["sterling"] = fnc(xsterling);
         
            return View();
        }

//*************************************//

<h2>Index</h2>

Dolar: @ViewData["dolar"]<hr />
Euro: @ViewData["euro"]<hr />
Sterling: @ViewData["sterling"]

3 Eylül 2012 Pazartesi

asp.net mvc de jQuery ajax ile post işlemi


var path='/Home/Update';
function (path, ID) {
        $.ajax({
                     url: path, type: 'POST',
                     success: function (msg) { alert(msg); },
                     data: { param1: ID} });
    }

//************************//

public JsonResult Update(int? param1)
        {
            //işlemler
            return Json("ok");
        }