I am trying to update a small section of razor syntax code in order to update the html string that is printed out every second so the user knows when a task is completed.
<!-- Start of first page: #viewAll -->
<div data-role="page" data-theme="a">
<div data-role="header" data-theme="a" data-position="fixed" data-tap-toggle="false">
<a href="#popupDialog" data-icon="delete" data-iconpos="notext" data-rel="popup" data-position-to="window" data-role="button" data-transition="pop">Log Off</a>
<h1>Time Sheet Information</h1>
<a href="#popupPanel" data-rel="popup" data-transition="slide" data-iconpos="notext" data-position-to="window" data-icon="grid" data-role="button">Nav</a>
</div>
<div data-role="popup" id="popupPanel" data-corners="false" data-theme="none" data-shadow="false" data-tolerance="0,0">
<button data-theme="c" data-icon="back" name= "Projects" value="Projects">Projects</button>
<button data-theme="c" data-icon="grid" name= "News" value="News">News</button>
<button data-theme="c" data-icon="search" name= "Profile" value="Profile">Profile</button>
</div>
<div data-role="popup" id="popupDialog" data-overlay-theme="a" data-theme="c" style="max-width:400px;" class="ui-corner-all">
<div data-role="header" data-theme="a" class="ui-corner-top">
<h1></h1>
</div>
<div data-role="content" data-theme="d" class="ui-corner-bottom ui-content">
<h3 class="ui-title">Are you sure you want to sign off?</h3>
<p>Click "No" to stay on current page.</p>
<form action="" method="post" data-ajax="false"> <!-- Form -->
<center><a href="" data-role="button" data-inline="true" data-rel="back" data-theme="c">No</a>
<button data-theme="a" data-role="button" data-inline="true" data-rel="back" data-transition="flow" name="logoff" value="logoff" data-theme="b">Yes</a>
</center></form>
</div>
</div>
<div data-role="content" data-theme="a">
@{
//View all TS data
AccessSqlData viewAllDataSource = new AccessSqlData(context.connectionReporting, "SELECT [PeriodName], [PeriodStatus], [TimesheetName], [PeriodStartDate], [PeriodEndDate], [TimesheetStatus], SUM(ActualWorkBillable) AS ActualWorkBillable, [ResourceName] FROM [MSP_TimesheetLine_UserView] WHERE [ResourceName] = '" + context.getResourceName + "' GROUP BY [PeriodName], [PeriodStatus], [TimesheetName], [PeriodStartDate], [PeriodEndDate], [TimesheetStatus], [ResourceName] ORDER BY CONVERT(DateTime, PeriodName,101) DESC");
datatab = viewAllDataSource.retrieveDataTable();
string viewAllString= "";
timesheetPrinter viewAllPrinter = new timesheetPrinter();
if (datatab.Rows.Count < 1)
{
<p>You have no Time Sheet data saved on your Project Server account</p>
}
else
{
foreach (DataRow dr in datatab.Rows)
{
viewAllString = viewAllString + viewAllPrinter.retrievePrintedTS(dr);
}
}
}
@Html.Raw(viewAllString)
</div>
<div data-role="footer" data-theme="b" class="footer" data-position="fixed" data-tap-toggle="false">
<div data-role="navbar">
<ul>
<li><a href="ViewAll.cshtml" data-role="button" data-transition="slide" class="ui-btn-active ui-state-persist">View All</a></li>
<li><a href="ViewOpen.cshtml" data-role="button" data-transition="slide">Open</a></li>
<li><a href="ViewClosed.cshtml" data-role="button" data-transition="slide">Closed</
@{
//View all TS data
AccessSqlData viewAllDataSource = new AccessSqlData(context.connectionReporting, "SELECT [PeriodName], [PeriodStatus], [TimesheetName], [PeriodStartDate], [PeriodEndDate], [TimesheetStatus], SUM(ActualWorkBillable) AS ActualWorkBillable, [ResourceName] FROM [MSP_TimesheetLine_UserView] WHERE [ResourceName] = '" + context.getResourceName + "' GROUP BY [PeriodName], [PeriodStatus], [TimesheetName], [PeriodStartDate], [PeriodEndDate], [TimesheetStatus], [ResourceName] ORDER BY CONVERT(DateTime, PeriodName,101) DESC");
datatab = viewAllDataSource.retrieveDataTable();
string viewAllString= "";
timesheetPrinter viewAllPrinter = new timesheetPrinter();
if (datatab.Rows.Count < 1)
{
<p>You have no Time Sheet data saved on your Project Server account</p>
}
else
{
foreach (DataRow dr in datatab.Rows)
{
viewAllString = viewAllString + viewAllPrinter.retrievePrintedTS(dr);
}
}
}
@Html.Raw(viewAllString)
This is the section I need to constantly update every second and I am looking for appropriate ways to do this as I am fairly new to razor in general.
I was wondering whether or not I could put the bolded code in another file, and then use AJAX calls in order to constantly call that section within this document so that it refreshes.
afire007
Member
17 Points
74 Posts
Constantly update information every second
Jan 22, 2013 03:09 PM|LINK
Hello everyone,
I am trying to update a small section of razor syntax code in order to update the html string that is printed out every second so the user knows when a task is completed.
<!-- Start of first page: #viewAll --> <div data-role="page" data-theme="a"> <div data-role="header" data-theme="a" data-position="fixed" data-tap-toggle="false"> <a href="#popupDialog" data-icon="delete" data-iconpos="notext" data-rel="popup" data-position-to="window" data-role="button" data-transition="pop">Log Off</a> <h1>Time Sheet Information</h1> <a href="#popupPanel" data-rel="popup" data-transition="slide" data-iconpos="notext" data-position-to="window" data-icon="grid" data-role="button">Nav</a> </div> <div data-role="popup" id="popupPanel" data-corners="false" data-theme="none" data-shadow="false" data-tolerance="0,0"> <button data-theme="c" data-icon="back" name= "Projects" value="Projects">Projects</button> <button data-theme="c" data-icon="grid" name= "News" value="News">News</button> <button data-theme="c" data-icon="search" name= "Profile" value="Profile">Profile</button> </div> <div data-role="popup" id="popupDialog" data-overlay-theme="a" data-theme="c" style="max-width:400px;" class="ui-corner-all"> <div data-role="header" data-theme="a" class="ui-corner-top"> <h1></h1> </div> <div data-role="content" data-theme="d" class="ui-corner-bottom ui-content"> <h3 class="ui-title">Are you sure you want to sign off?</h3> <p>Click "No" to stay on current page.</p> <form action="" method="post" data-ajax="false"> <!-- Form --> <center><a href="" data-role="button" data-inline="true" data-rel="back" data-theme="c">No</a> <button data-theme="a" data-role="button" data-inline="true" data-rel="back" data-transition="flow" name="logoff" value="logoff" data-theme="b">Yes</a> </center></form> </div> </div> <div data-role="content" data-theme="a"> @{ //View all TS data AccessSqlData viewAllDataSource = new AccessSqlData(context.connectionReporting, "SELECT [PeriodName], [PeriodStatus], [TimesheetName], [PeriodStartDate], [PeriodEndDate], [TimesheetStatus], SUM(ActualWorkBillable) AS ActualWorkBillable, [ResourceName] FROM [MSP_TimesheetLine_UserView] WHERE [ResourceName] = '" + context.getResourceName + "' GROUP BY [PeriodName], [PeriodStatus], [TimesheetName], [PeriodStartDate], [PeriodEndDate], [TimesheetStatus], [ResourceName] ORDER BY CONVERT(DateTime, PeriodName,101) DESC"); datatab = viewAllDataSource.retrieveDataTable(); string viewAllString= ""; timesheetPrinter viewAllPrinter = new timesheetPrinter(); if (datatab.Rows.Count < 1) { <p>You have no Time Sheet data saved on your Project Server account</p> } else { foreach (DataRow dr in datatab.Rows) { viewAllString = viewAllString + viewAllPrinter.retrievePrintedTS(dr); } } } @Html.Raw(viewAllString) </div> <div data-role="footer" data-theme="b" class="footer" data-position="fixed" data-tap-toggle="false"> <div data-role="navbar"> <ul> <li><a href="ViewAll.cshtml" data-role="button" data-transition="slide" class="ui-btn-active ui-state-persist">View All</a></li> <li><a href="ViewOpen.cshtml" data-role="button" data-transition="slide">Open</a></li> <li><a href="ViewClosed.cshtml" data-role="button" data-transition="slide">Closed</@{ //View all TS data AccessSqlData viewAllDataSource = new AccessSqlData(context.connectionReporting, "SELECT [PeriodName], [PeriodStatus], [TimesheetName], [PeriodStartDate], [PeriodEndDate], [TimesheetStatus], SUM(ActualWorkBillable) AS ActualWorkBillable, [ResourceName] FROM [MSP_TimesheetLine_UserView] WHERE [ResourceName] = '" + context.getResourceName + "' GROUP BY [PeriodName], [PeriodStatus], [TimesheetName], [PeriodStartDate], [PeriodEndDate], [TimesheetStatus], [ResourceName] ORDER BY CONVERT(DateTime, PeriodName,101) DESC"); datatab = viewAllDataSource.retrieveDataTable(); string viewAllString= ""; timesheetPrinter viewAllPrinter = new timesheetPrinter(); if (datatab.Rows.Count < 1) { <p>You have no Time Sheet data saved on your Project Server account</p> } else { foreach (DataRow dr in datatab.Rows) { viewAllString = viewAllString + viewAllPrinter.retrievePrintedTS(dr); } } } @Html.Raw(viewAllString)This is the section I need to constantly update every second and I am looking for appropriate ways to do this as I am fairly new to razor in general.
I was wondering whether or not I could put the bolded code in another file, and then use AJAX calls in order to constantly call that section within this document so that it refreshes.
ignatandrei
All-Star
134947 Points
21626 Posts
Moderator
MVP
Re: Constantly update information every second
Jan 22, 2013 06:46 PM|LINK
Ajax . Please see http://bit.ly/mvc_ajax_jquery
chetan.sarod...
All-Star
65749 Points
11148 Posts
Re: Constantly update information every second
Jan 23, 2013 02:23 AM|LINK
http://forums.asp.net/t/1665499.aspx/1?Update+panel+and+timer+in+ASP+net+MVC
http://stackoverflow.com/questions/5939050/ajax-updatepanel-timer-functions-in-mvc-3-0
hope this helps...
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.