Currently I am developing a site where users can update a metrics and display weight lost/gain over time, I have created the charts from the database and displayed using <img src="Weight.cshtml" /> inside my site.
This works fine except I need the chart to display the current user
int userId = WebSecurity.CurrentUserId;
A fix for this would be to put the chart straight into my app page, not using the img src
Can I do that
Thanks
Marked as answer by heaga77 on Feb 25, 2012 08:22 PM
You can use WebSecurity.CurrentUserId in Weight.cshtml to generate a personalised chart.
So I used this code inside the the weight.cshtml, is the sql statement right,
int userId = WebSecurity.CurrentUserId;
var db = Database.Open("MyDataBase");
var data = db.Query("SELECT Date, Weight FROM Metrics Where UserId = userId ");
var key = new Chart(width: 600, height: 400, theme: ChartTheme.Blue)
Then I placed a reference of weight.cshtml with an img in another file, this does not update the chart to the current user database data,
I use this sql to check the databse connection works
var data = db.Query("SELECT Date, Weight FROM Metrics Where UserId = 15 ");
heaga77
Member
2 Points
3 Posts
Chart display using current userID
Feb 21, 2012 11:56 PM|LINK
Hi,
Currently I am developing a site where users can update a metrics and display weight lost/gain over time, I have created the charts from the database and displayed using <img src="Weight.cshtml" /> inside my site.
This works fine except I need the chart to display the current user
int userId = WebSecurity.CurrentUserId;
A fix for this would be to put the chart straight into my app page, not using the img src
Can I do that
Thanks
Mikesdotnett...
All-Star
155597 Points
19981 Posts
Moderator
MVP
Re: Chart display using current userID
Feb 22, 2012 04:29 AM|LINK
You can use WebSecurity.CurrentUserId in Weight.cshtml to generate a personalised chart.
Web Pages CMS | My Site | Twitter
heaga77
Member
2 Points
3 Posts
Re: Chart display using current userID
Feb 22, 2012 09:18 AM|LINK
So I used this code inside the the weight.cshtml, is the sql statement right,
int userId = WebSecurity.CurrentUserId;
var db = Database.Open("MyDataBase");
var data = db.Query("SELECT Date, Weight FROM Metrics Where UserId = userId ");
var key = new Chart(width: 600, height: 400, theme: ChartTheme.Blue)
Then I placed a reference of weight.cshtml with an img in another file, this does not update the chart to the current user database data,
I use this sql to check the databse connection works
var data = db.Query("SELECT Date, Weight FROM Metrics Where UserId = 15 ");
This renders the chart for that user.
Thanks for your help in advance.
Mikesdotnett...
All-Star
155597 Points
19981 Posts
Moderator
MVP
Re: Chart display using current userID
Feb 22, 2012 12:29 PM|LINK
var data = db.Query("SELECT Date, Weight FROM Metrics Where UserId = @0", userId);
Web Pages CMS | My Site | Twitter