milosev.com
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home

Debug JavaScript in Visual Studio 2010

Details
Written by: Stanko Milosev
Category: ASP.NET
Published: 04 March 2013
Last Updated: 13 March 2013
Hits: 6025

Use the JavaScript debugger keyword in IE.

function onClickRow(detailUrl) {
    debugger;
}

Copy / paste from here.

Same thing should work for Chrome, if it doesn't then rebuild your project.

Playing with XML

Details
Written by: Stanko Milosev
Category: MVC 4
Published: 22 October 2013
Last Updated: 15 September 2020
Hits: 5666
  • xml

I had XML like this:

<?xml version="1.0" encoding="utf-8"?>
<ArrayOfmyNode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <myNode>
    <Name>Echo one</Name>
    <Category>Reporting</Category>
    <Id>1</Id>
    <Workflow>
      <Application>Reporting</Application>
      <Name>EchoOne</Name>
      <Configuration>
        <ConfigItem>
          <Key>ReportSuccessToAddress</Key>
          <Value>echoOneSuccess - at - echoone.com</Value>
        </ConfigItem>
        <ConfigItem>
          <Key>ReportErrorToAddress</Key>
          <Value>echoOneError - at - echoone.com</Value>
        </ConfigItem>
        <ConfigItem>
          <Key>ReportSuccessCcAddress</Key>
          <Value>echoOneSuccessCc - at - echoone.com</Value>
        </ConfigItem>
      </Configuration>
    </Workflow>
  </myNode>
  <myNode>
    <Name>Echo two</Name>
    <Category>Reporting</Category>
    <Id>2</Id>
    <Workflow>
      <Application>Reporting</Application>
      <Name>EchoTwo</Name>
      <Configuration>
        <ConfigItem>
          <Key>ReportSuccessToAddress</Key>
          <Value>echoTwoSuccess - at - echoone.com</Value>
        </ConfigItem>
        <ConfigItem>
          <Key>ReportErrorToAddress</Key>
          <Value>echoTwoError - at - echoone.com</Value>
        </ConfigItem>
        <ConfigItem>
          <Key>ReportSuccessCcAddress</Key>
          <Value>echoTwoSuccessCc - at - echoone.com</Value>
        </ConfigItem>
      </Configuration>
    </Workflow>
  </myNode>
 </ArrayOfmyNode>

Instead of - at - should be @, I am having problems with spambot protection :)

And I wanted to extract all e-mails from ReportSuccessToAddress, ReportErrorToAddress and ReportSuccessCcAddress nodes.

Model I implemented as array in my view:

@model PlayingWithXmlInAspMvc.Models.PlayingWithXmlModel[]

Then I had to load XML from file:

XElement linqMyNodes = XElement.Load(Request.Url.AbsoluteUri + "PlayingWithXml.xml"); 

If you need to load XML from string, then use parse.

I have selected all myNode nodes in the XML:

IEnumerable<XElement> myLinqNodes = from myNodes in linqMyNodes.Elements("myNode") select myNodes;

After that in controller I have created model like:

PlayingWithXmlModel[] myModel = new PlayingWithXmlModel[myLinqNodes.Count()];

Extract every ConfigItem element for each myNode:

foreach (var myLinqNode in myLinqNodes)
{
	myModel[i] = new PlayingWithXmlModel();
	var Configurations = from configuration in myLinqNode.Elements("Workflow").Elements("Configuration").Elements("ConfigItem")
						 select configuration;
}

In previous line there is myModel[i] = new PlayingWithXmlModel(), which means that for every item in array you have to create object, in my case model.

Now I need to extract addresses from Configurations:

foreach (var Configuration in Configurations)
{
	if (Configuration.Element("Key") != null)
	{
		switch (Configuration.Element("Key").Value)
		{
			case "ReportSuccessToAddress":
				myModel[i].ReportSuccessToAddress = Configuration.Element("Value").Value.Replace(" ", string.Empty);
				break;
			case "ReportErrorToAddress":
				myModel[i].ReportErrorToAddress = Configuration.Element("Value").Value.Replace(" ", string.Empty);
				break;
			case "ReportSuccessCcAddress":
				myModel[i].ReportSuccessCcAddress = Configuration.Element("Value").Value.Replace(" ", string.Empty);
				break;
		}
	}
}

Where .Replace(" ", string.Empty) I needed to delete spaces in values.

On the end I will send model to my view like:

return View(myModel);

This article is just to show few examples of LinqToXml and passing model as array to the view. One small example you can see here.

Routing

Details
Written by: Stanko Milosev
Category: MVC 4
Published: 09 October 2013
Last Updated: 05 April 2022
Hits: 5694

After creating controllers, for instance, like in example which I described here, and you want to "extend" index controller with additional parameter, then you have to introduce new router. In my case, in RouteConfig.cs (\MasterDetailDataTables\MasterDetailDataTables\App_Start\RouteConfig.cs) I did something like this:

 

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            //routes.MapRoute(
            //    name: "Default",
            //    url: "{controller}/{action}/{id}",
            //    defaults: new { controller = "MasterDetail", action = "Index", id = UrlParameter.Optional }
            //);

            routes.MapRoute(
                name: "MasterDetail",
                url: "{controller}/{action}/{category}",
                defaults: new { controller = "MasterDetail", action = "Index", category = UrlParameter.Optional }
            );
        }

As you can see, I commented default one, and added new one, where instead id I wrote category. Also in this line:

defaults: new { controller = "MasterDetail", action = "Index", category = UrlParameter.Optional }

Category is bold because I already forgot to change it in there part as well :)

From here.

SQL Compact - create table

Details
Written by: Stanko Milosev
Category: MVC 4
Published: 25 September 2013
Last Updated: 30 November -0001
Hits: 5298

Like this:

I have created table named "SqlCompact", with two fields Id and Name, where Id is not nullable and identity is set to true:

  1. SQL Compact
  2. Master - detail with datatables
  3. Datatables (start empty MVC4 project)
  4. Local or cloud configuration

Subcategories

C#

Azure

ASP.NET

JavaScript

Software Development Philosophy

MS SQL

IBM WebSphere MQ

MySQL

Joomla

Delphi

PHP

Windows

Life

Lazarus

Downloads

Android

CSS

Chrome

HTML

Linux

Eclipse

Page 43 of 164

  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47