I am trying to experiment Single Page Application on ASP.NET MVC 4, using video demo at
http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2159. I do not have any problem to write all code from the video. I have to add System.Web.Http.Data.Helpers2 manually. When I define code "var
dataSource = upshot.dataSources.DeliveriesForToday;" there is no intellisense for "dataSources". This is
make the allert is not show at run time.
"Now I am stuck on the allert statement at the following code:
@using DeliveryTracker.Controllers
@section featured {
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h1>Welcome to my Single Page Application</h1>
</hgroup>
</div>
</section>
}
@(Html.UpshotContext().DataSource<DataServicesController>(x => x.GetDeliveriesForToday()))
<script type="text/javascript">
$(function () {
var dataSource = upshot.dataSources.DeliveriesForToday;
dataSource.refresh(function (results) {
alert(results);
});
});
</script>
Is there any other requirement to use Knockout.js so I can be able to continue to try the demo?
modify Index.cshtml at /Views/Home/ folder See the insert:
The problem is: "var dataSource = upshot.dataSources.GetDeliveriesForToday" is not happy there is no intellisense for "dataSources" and "GetDeliveriesForToday", and dataSource.refresh(function (results) { alert(results); }); is not working, there
is no allert windows
@using DeliveryTracker.Controllers
@section featured {
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h1>Welcome to my Single Page Application</h1>
</hgroup>
</div>
</section>
}
@(Html.UpshotContext().DataSource<DataServicesController>(x => x.GetDeliveriesForToday()))
<script type="text/javascript">
$(function () {
var dataSource = upshot.dataSources.DeliveriesForToday;
dataSource.refresh(function (results) {
alert(results);
});
});
</script>
You don't have any intellisense on that because the objects like
DeliveriesForToday doesn't exist yet. In your code example the datasource name is
DeliveriesForToday, but in your text you said it called "GetDeliveriesForToday". I think that is your problem. You need to call it like in your code sample. If that wouldn't work, I would recomend you to startup
the page and look what's inserted in code.
The "@(Html.UpshotContext().DataSource<DataServicesController>(x => x.GetDeliveriesForToday()))" line of code generates some code for you, and also sets the datasource name you can use in your personal code.
Thank you for reply after a week of waiting, I also comment this case on SPA page, but no answer.
I have correct to be the following code, but still the same. When I use this on browse data exist http://localhost:3713/api/DataServices/GetDeliveriesForToday, but when I run after
I modified, still do not show my allert. Here the code I modified:
@using DeliveryTracker.Controllers
@section featured {
<section class="featured">
<div class="content-wrapper">
<hgroup class="title">
<h1>Welcome to my Single Page Application</h1>
</hgroup>
</div>
</section>
}
@(Html.UpshotContext().DataSource<DataServicesController>(x => x.GetDeliveriesForToday()))
<script type="text/javascript">
$(function () {
var dataSource = upshot.dataSources.GetDeliveriesForToday;
dataSource.refresh(function (results) {
alert(results);
});
});
</script>
I looked back to the video, is not "var dataSource = upshot.dataSources.GetDeliveriesForToday;" but without get "var
dataSource = upshot.dataSources.DeliveriesForToday;"
I really do not understand what I am doing wrong, but at the video demo on the TechDay in Netherland, it worked
I am glad that you have done sucesfull. When I activate developer tools (F12) there is no message on Chrome, but on IE it stop at
var dataSource = upshot.dataSources.DeliveriesForToday;
I tried the calssicall debug like this the following code:
That is strange, since "var dataSource
= upshot.dataSources.DeliveriesForToday;" isn't even executing any code. The call
to the server is only launched when the refresh method is called.
My guess is that you are missing some references. In the _SpaScripts.cshtml in the shared folder you should have the following:
jsiahaan
Contributor
2552 Points
646 Posts
Single Page Application - Prerequirement
Apr 02, 2012 10:12 AM|LINK
Hi,
I am trying to experiment Single Page Application on ASP.NET MVC 4, using video demo at http://channel9.msdn.com/Events/TechDays/Techdays-2012-the-Netherlands/2159. I do not have any problem to write all code from the video. I have to add System.Web.Http.Data.Helpers2 manually. When I define code "var dataSource = upshot.dataSources.DeliveriesForToday;" there is no intellisense for "dataSources". This is make the allert is not show at run time.
"Now I am stuck on the allert statement at the following code:
@using DeliveryTracker.Controllers @section featured { <section class="featured"> <div class="content-wrapper"> <hgroup class="title"> <h1>Welcome to my Single Page Application</h1> </hgroup> </div> </section> } @(Html.UpshotContext().DataSource<DataServicesController>(x => x.GetDeliveriesForToday())) <script type="text/javascript"> $(function () { var dataSource = upshot.dataSources.DeliveriesForToday; dataSource.refresh(function (results) { alert(results); }); }); </script>Is there any other requirement to use Knockout.js so I can be able to continue to try the demo?
Thank you in advance
Indonesian Humanitarian Foundation
jsiahaan
Contributor
2552 Points
646 Posts
Re: Single Page Application - Prerequirement
Apr 02, 2012 02:00 PM|LINK
Hi,
I have tried to start over from the beginning again with the following steps:
@using DeliveryTracker.Controllers @section featured { <section class="featured"> <div class="content-wrapper"> <hgroup class="title"> <h1>Welcome to my Single Page Application</h1> </hgroup> </div> </section> } @(Html.UpshotContext().DataSource<DataServicesController>(x => x.GetDeliveriesForToday())) <script type="text/javascript"> $(function () { var dataSource = upshot.dataSources.DeliveriesForToday; dataSource.refresh(function (results) { alert(results); }); }); </script>Any one can help me please?
Indonesian Humanitarian Foundation
KDegrave
Member
96 Points
25 Posts
Re: Single Page Application - Prerequirement
Apr 07, 2012 06:44 AM|LINK
hi,
You don't have any intellisense on that because the objects like DeliveriesForToday doesn't exist yet. In your code example the datasource name is DeliveriesForToday, but in your text you said it called "GetDeliveriesForToday". I think that is your problem. You need to call it like in your code sample. If that wouldn't work, I would recomend you to startup the page and look what's inserted in code.
The "@(Html.UpshotContext().DataSource<DataServicesController>(x => x.GetDeliveriesForToday()))" line of code generates some code for you, and also sets the datasource name you can use in your personal code.
Kristof
Ria4HTML: http://ria4htmldemo.codeplex.com
Linq2IndexedDB: http://linq2indexeddb.codeplex.com
jsiahaan
Contributor
2552 Points
646 Posts
Re: Single Page Application - Prerequirement
Apr 07, 2012 07:00 AM|LINK
Thank you for reply after a week of waiting, I also comment this case on SPA page, but no answer.
I have correct to be the following code, but still the same. When I use this on browse data exist http://localhost:3713/api/DataServices/GetDeliveriesForToday, but when I run after I modified, still do not show my allert. Here the code I modified:
@using DeliveryTracker.Controllers @section featured { <section class="featured"> <div class="content-wrapper"> <hgroup class="title"> <h1>Welcome to my Single Page Application</h1> </hgroup> </div> </section> } @(Html.UpshotContext().DataSource<DataServicesController>(x => x.GetDeliveriesForToday())) <script type="text/javascript"> $(function () { var dataSource = upshot.dataSources.GetDeliveriesForToday; dataSource.refresh(function (results) { alert(results); }); }); </script>Indonesian Humanitarian Foundation
jsiahaan
Contributor
2552 Points
646 Posts
Re: Single Page Application - Prerequirement
Apr 07, 2012 07:26 AM|LINK
Hi Kristof,
I looked back to the video, is not "var dataSource = upshot.dataSources.GetDeliveriesForToday;" but without get "var dataSource = upshot.dataSources.DeliveriesForToday;"
I really do not understand what I am doing wrong, but at the video demo on the TechDay in Netherland, it worked
Again I have try them both, no luck
Indonesian Humanitarian Foundation
KDegrave
Member
96 Points
25 Posts
Re: Single Page Application - Prerequirement
Apr 07, 2012 07:39 AM|LINK
Did you builde the solution completelly by your self, or have you download it?
I'm currently working on it, but I don't have any problems. So the following just works for me.
@(Html.UpshotContext(bufferChanges: true).DataSource<DataServiceController>(x => x.GetDeliveriesForToday())) <script type="text/javascript"> $(function () { var dataSource = upshot.dataSources.DeliveriesForToday; dataSource.refresh(function (results) { alert(results); }); }); </script>But, can u discribe what kind of error you get? Have you try looking with the developer tools (F12) maybe there is some js error?
Ria4HTML: http://ria4htmldemo.codeplex.com
Linq2IndexedDB: http://linq2indexeddb.codeplex.com
jsiahaan
Contributor
2552 Points
646 Posts
Re: Single Page Application - Prerequirement
Apr 07, 2012 08:05 AM|LINK
Hi Kristof,
I am glad that you have done sucesfull. When I activate developer tools (F12) there is no message on Chrome, but on IE it stop at var dataSource = upshot.dataSources.DeliveriesForToday;
I tried the calssicall debug like this the following code:
<script type="text/javascript"> $(function () { alert("alert 1"); var dataSource = upshot.dataSources.DeliveriesForToday; alert("alert 2") dataSource.refresh(function (results) { alert(results); }); }); </script>I have "alert1" on test run, but there is no "alert 2"
Indonesian Humanitarian Foundation
jsiahaan
Contributor
2552 Points
646 Posts
Re: Single Page Application - Prerequirement
Apr 07, 2012 08:13 AM|LINK
Sorry I forgot to answer this quote.
I build it my self, and I add AppDbContext.cs, and DomainModels.cs from the sample I have download earlier
Indonesian Humanitarian Foundation
KDegrave
Member
96 Points
25 Posts
Re: Single Page Application - Prerequirement
Apr 07, 2012 08:20 AM|LINK
That is strange, since "var dataSource = upshot.dataSources.DeliveriesForToday;" isn't even executing any code. The call to the server is only launched when the refresh method is called.
My guess is that you are missing some references. In the _SpaScripts.cshtml in the shared folder you should have the following:
Also check if you have the latest version of the SPA: open your packetmanager and search for SinglePageApplication.CSharp
I don't know if it is the Web API that you want to use, but I have made a demo app with upshot and knockout for RIA services.
You can find the demo here. and a guiding tutorial here.
Kristof
Ria4HTML: http://ria4htmldemo.codeplex.com
Linq2IndexedDB: http://linq2indexeddb.codeplex.com
KDegrave
Member
96 Points
25 Posts
Re: Single Page Application - Prerequirement
Apr 07, 2012 08:31 AM|LINK
I'm thinking you are missing some references. You need at least the following:
Also make sure you have the latest version of SinglePageApplications installed. You can do this with nuget.
I have builded a demo app with RIA Services, you can find it over here and wrote a guiding post.
Ria4HTML: http://ria4htmldemo.codeplex.com
Linq2IndexedDB: http://linq2indexeddb.codeplex.com