|
I'm very new to web development, so forgive my ignorance...
I've got a grid on a page, and it loads fine on startup. I then receive an event from a SignalR service. I want to reload the grid at this point. Here's my controller:
public class HomeController : Controller
{
private IDataAccess _dal;
private DashboardClientProxy _dashboardProxy;
private bool _isConnected = false;
public HomeController()
{
_dal = new DataAccess();
_dashboardProxy = new DashboardClientProxy();
_dashboardProxy.ResultsAdded += _dashboardProxy_ResultsAdded;
try
{
_dashboardProxy.Connect();
}
catch (Exception e)
{
throw e;
}
}
public ActionResult Index()
{
var data = _dal.GetDashboardInfos(new DashboardInfoQueryArgs());
return View(data);
}
private void _dashboardProxy_ResultsAdded(object sender, EventArgs data)
{
RedirectToAction("Index", "HomeController");
}
}
I thought that by calling "RedirectToAction("Index", "HomeController") that the Index method would be run again, yet it doesn't work.
What am I doing wrong here?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
RedirectToAction returns a result to the client telling it to make a new request to the specified action. But it only works in response to a request from the client.
If it fires at all, your event is being fired on a background thread, long after the index view has been rendered. The client is no longer connected to your server, and is not waiting for a response.
But I suspect it will never fire. I believe the default is for MVC to create a new instance of your controller class for each request, and dispose of it once the request has completed. Since the controller owns the object which raises the event, there will be no reachable references to the instance, so both the controller and the proxy will be deleted.
Instead, you'll need to have the client connect directly to your SignalR hub in Javascript. It will need to listen for the event, and when it receives the event, either reload the page, or make an AJAX request to reload just the grid.
ASP.NET SignalR Hubs API Guide - JavaScript Client | Microsoft Docs[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I am using MVCGrid.Net.
From what I can see from their documentation the GridColum doesn't have a width property.
Anyone used this grid before? Any way to set a column's width?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
What about:
CellCssClassExpression Func<T1, GridContext, string> Use this to specify a custom css class based on data for the current cell
I thought CSS allowed you to specify width of a field.
|
|
|
|
|
Hello.,
Here's my thing, I have a website that was created with MS Publisher and I used to modify and upload the information through core ftp lite. This website gets the job done with the pictures and information but now I need something more up to date and dynamic. I bought a hosting plan to Hostgator and was trying to use the wordpress and joomla thing but it seems a bit complicated and it's not as easy as I thought it would be when I created a free website in WIX. So I'd like to know what options do I have to build the website and what software is recommended to edit and upload all the stuff. My budget is limited now and my business is not that big so I don't think I could hire a Pro in the matter.
Thanks.
|
|
|
|
|
Did you know WordPress and Joomla etc come shipped with some good looking themes by default? Just go the Appearance or Theme tabs and you can find thousands of themes that can be applied to your website in seconds. Secondly, you can get access to the content of the template as well, if you want to update or modify the templates.
So, even if you are not a pro, or can't afford one you can still get the website's theme up to date by selecting from a lot of the available ones on the gallery.
As for the deployment options, WordPress and Joomla do provide an online editor for you to edit your content from the control panel. Otherwise, there is a tool by Microsoft WebMatrix, that is provided free of cost and is fully capable of editing PHP websites. Visual Studio Code is also available, if you are somewhat happy with editing of the application yourself. Otherwise, they got your back — and their hands in your pocket.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
|
Could you please suggest me how i can make this concept ,if time1<time2, so="" it="" will="" add="" +1="" in="" time1,="" i="" explain="" this="" example="" suppose="" the="" time2="" is="" 07:40="" am="" and="" time1="" 1:00="" now="" become="" 25="" or="" 2:00="" 26="" but="" if="" value="" 07:41="" work="" as="" a="" normal="" .
<pre="" lang="Javascript">
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<div ng-app="myapp">
Time1 :<br><input type="time" id="time1" name="time1" ng-model="time1" placeholder="HH:mm" required /><br>
<br>
Time2 :<br><input type="time" id="time2" name="time2" ng-model="time2" placeholder="HH:mm" required />
<p> Your Time is ans is {{(time1-time2)| correcttime | date: 'HH:mm': 'UTC'}} </p>
</div>
<script>
var app = angular.module('myApp', []);
app.filter('correcttime', function() {
if {
time1>24;
time1=+1;
}
else if {
time1=time2;
time1-time2==0;
}
else{
time1-time2;
}
return function(num) { return Math.abs(num); }
});
</script>
</body>
</html>
modified 16-Feb-17 20:32pm.
|
|
|
|
|
I am not an expert in AngularJS, but looking at the following code:
if {
time1>24;
time1=+1;
}
else if {
time2=time2;
time1==0;
}
else{
time1-time2;
}
I would be happy to read an explanation of why my assumptions are wrong.
|
|
|
|
|
I was going to comment on the lack of a controller, the capitalization issue, and the malformed conditional statements, but no real point until the core logic is sorted.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
|
does any body know any opensource mvc discussion forum/board to include in existing mvc project?
|
|
|
|
|
|
I'm not sure why you were downvoted since this is an area to discuss topics. Upvoted to counter.
And no, I don't know of any.
There are two kinds of people in the world: those who can extrapolate from incomplete data.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I want to use Google Translate in a new website I am developing. I have created the code I want on the Goggle site and it works very well when I run it in the website.
The only problem I have is that it won't position itself where I want it. I am trying to place it at the bottom right hand corner of my site alongside the Copyright notice under the site footer.
I am using W3.CSS to provide me responsiveness and have created the following code.
<div class="w3-display-container w3-row">
<div class="w3-col">
</div>
<div class="w3-col w3-center w3-small">
Copyright statement appears here
</div>
<div class="w3-col w3-right w3-top">
<p>Translate this page:</p>
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({ pageLanguage: 'en' }, 'google_translate_element');}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
</div>
</div>
I've tried recoding this a number of different ways and it hasn't yet appeared where I want it. It has appeared above the header area, in the header area and under the header area on both the right and left of the webpage.
Any help would be most welcome.
Oh, by the way, Bing Translate behaves in a similar way.
|
|
|
|
|
The div with id "google_translate_element" is the one which shows the translator button. So style that only. Keep it on the footer of your site the add the style like this -
#google_translate_element
{
float:right:
}
|
|
|
|
|
Thanks for your reply
It does indeed float the element to the right but it is still positioned at the top of the Header area when I open the web page. When I scroll the page, the element doesn't move its position on the screen. It just scrolls down the webpage maintaining a fixed position relative to the monitor not the web page. I just don't understand this at all ???
|
|
|
|
|
I think postion:fixed is getting applied to the div.Since you don't want it change it to absolute one by by replacing the html code by this:
<div class="w3-col w3-right w3-top" style="position:relative">
<p>Translate this page:</p>
<div id="google_translate_element" style="positon:absolute;top:10px;left:10px"></div>
<!--
</div>
</div>
By using the above code the translator div will be place 10 pixels from the top and 10pixels from the left of its parent which is the div with class "w3-col w3-right w3-top".
You can change the top and left values to adjust it more.
|
|
|
|
|
I have finally got it to a position I can live with. It is on the left hand side of the web page in the area I want it rather than the right hand side of that area. The code I have used is as follows:
<div class="w3-col" style="position:absolute; top:10px; left:10px" id="google_translate_element">
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({ pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, autoDisplay: false }, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
I really don't know what part of the code made it work this way, but hey, who cares - it works. The only problem is that this is a fixed position and therefore is not responsive on mobiles.
Many thanks for your help.
|
|
|
|
|
I've tried code this below but it gives me one record and it repeats 7 times. Wrong output. Can anyone has a good heart to figure it out please. Please see my complete code below. I'm just a newbie in programming. Sorry. Thank you.
===================================
OUTPUT: 1111111
===================================
_conn=new PDO("mysql:host=$this->_hostdb;dbname=$this->_namedb",$this->_userdb,$this-_passdb);
$this->_conn- >setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
if($this->_conn){
echo "Connected Successfully! ";
}
} catch (Exception $ex) {
echo ("Connection Failed!")." ".$ex->getMessage();
}
}
public static function getInstance(){
if(!isset(self::$_instance))
{
return self::$_instance=new DB();
}
}
public function processQuery($sql){
try{
$q=$this->_conn->prepare($sql);
$q->execute();
$q->setFetchMode(PDO::FETCH_ASSOC);
return $this->rowResult=$q->fetch();
} catch (Exception $ex) {
return ("Failed!")." ".$ex->getMessage();
}
}
public function getResultSet(){
return $this->rowResult;
}
//MAIN PROGRAM
$dbUser=DB::getInstance();
$user=$dbUser->processQuery("SELECT * FROM users");
for($i=0;$i<count($dbuser->rowResult);$i++){
echo $user['id'];
}
?>
modified 17-Jan-17 23:17pm.
|
|
|
|
|
I can see your for-loop influencing $user object
for($i=0;$i<count($dbUser->rowResult);$i++){
echo $user['id'];
}
Ashwin Shetty
|
|
|
|
|
Can you help me please what is the proper way. Thanks.
|
|
|
|
|
if you need to read data (forward only), you can write code like
$sql = "SELECT id, firstname, lastname FROM MyGuests";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "id: " . $row["id"];
}
} else {
echo "0 results";
}
$conn->close();
you can look at the sample available here
Ashwin Shetty
|
|
|
|
|
Thanks Ashwin for giving me ideas. I really appreciate it. I have managed to fix it.Please see my code below for main program.
=====================================
$dbUser=DB::getInstance();
$dbUser->processQuery("SELECT * FROM users");
echo count($dbUser->getResultSet());
foreach($dbUser->getResultSet() as $rows){
echo $rows['username'];
}
|
|
|
|
|
You are using fetch() which will not return anything but the first row.
Try return $this->rowResult=$q->fetchAll();
That will then return an array of the rows into $users which I think is what you were expecting.
|
|
|
|