|
OK, there were a few typos in my post, which should now be corrected:
- Missing "f" from
hourDiff within the if (endMinutes < startMinutes) block; - Missing
break statements from the switch clauses; - jQuery selectors should be
select[name$=...] instead of select[id$=...] due to changes in ASP.NET 4.0 ID generation;
I've updated my post with the Javascript code which should now work. The VB.NET code should look something like this:
Protected Sub ValidateDuration(ByVal sender As Object, ByVal args As ServerValidateEventArgs)
Dim validator As Control = DirectCast(sender, Control)
Dim row As Control = validator.NamingContainer
Dim startHour As Integer = Integer.Parse(DirectCast(row.FindControl("startHour"), DropDownList).SelectedValue)
Dim startMinutes As Integer = Integer.Parse(DirectCast(row.FindControl("startMinutes"), DropDownList).SelectedValue)
Dim startAmPm As String = DirectCast(row.FindControl("startAmPm"), DropDownList).SelectedValue
Select Case startAmPm
Case "AM"
If startHour = 12 Then
startHour = 0
End If
Case "PM"
If startHour <> 12 Then
startHour += 12
End If
Case Else
args.IsValid = True
Return
End Select
Dim endHour As Integer = Integer.Parse(DirectCast(row.FindControl("endHour"), DropDownList).SelectedValue)
Dim endMinutes As Integer = Integer.Parse(DirectCast(row.FindControl("endMinutes"), DropDownList).SelectedValue)
Dim endAmPm As String = DirectCast(row.FindControl("endAmPm"), DropDownList).SelectedValue
Select Case endAmPm
Case "AM"
If endHour = 12 Then
endHour = 0
End If
Case "PM"
If endHour <> 12 Then
endHour += 12
End If
Case Else
args.IsValid = True
Return
End Select
Dim hourDiff As Integer = endHour - startHour
If endMinutes < startMinutes Then
hourDiff -= 1
End If
args.IsValid = hourDiff >= 4
End Sub
The validator won't raise an error. Instead, as with any other validator control, the Page.IsValid property will return False . So your update method should look something like:
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSave.Click
If Page.IsValid Then
End If
End Sub
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Simply elegant Richard!
I now completely understand exactly what you did.
If minimum hour is less than 4, then the red asterick (*) is displayed.
It is working beautiful!
You have bailed me out again. Thank you soooo much, Richard.
I have got to figure out again, once more how to give you credit for the great work and then treat this thread as solved.
|
|
|
|
|
Read here to understand how element id created inside an ASP.NET template...
Understanding ASP.NET Templates[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
does anyone know how to check whether someone is a fan of a facebook page.
|
|
|
|
|
|
you can do like this after having the user permission
var user_id = 'USERID'
var page_id = 'YOUR PAGE ID';
var fql_query = 'SELECT uid FROM page_fan WHERE page_id = ' + page_id + ' and uid='+ user_id;
var query = FB.Data.query(fql_query);
query.wait(function (rows) {
if (rows.length == 1 && rows[0].uid == user_id) {
//IS A FAN OF THE PAGE
} else {
//NOT A FAN OF THE PAGE
}
});
|
|
|
|
|
<!DOCTYPE html>
<html>
<head>
<script src="//maps.googleapis.com/maps/api/js?sensor=false"type="text/javascript"></script>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
<style type="text/css">
html, body, #map-canvas {
height: 100%;
margin: 0;
}
</style>
<script type="text/javascript">
= "select * from gps ORDER BY id DESC LIMIT 1"= mysql_query($sqlgps)= mysql_fetch_array($result);
?
var map; // add map make
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(, ),
zoom: 17,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map-canvas"),
mapOptions);
//load();
}
function make(){
var marker = new google.maps.Marker({
position: new google.maps.LatLng(, ), // auto refresh marker fram database mysql
//position: map.getCenter(),
draggable:true, // make move click
animation:google.maps.Animation.DROP,
map: map,
title: "Welcome to Thailand",
//icon: "http://maps.google.com/mapfiles/ms/micons/blue.png"
});
//
}
google.maps.event.addDomListener(window, 'load', initialize);
window.onload = make;
</script>
</head>
<body ">
<div id="map-canvas"></div>
</body>
</html>
|
|
|
|
|
I want to know what is the main purpose of the angular js can u axplain with any live example in asp.net
thanx
|
|
|
|
|
Ever considered to visit here: https://angularjs.org/[^]?
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
AngularJS is a MVC framework for client-side. You can use it for building an Single Page Application easily.
|
|
|
|
|
I have the below code, I want to display Temprature -> Metric value ?
[
{
LocalObservationDateTime: "2014-06-30T11:40:00+05:30",
EpochTime: 1404108600,
WeatherText: "Mostly cloudy",
WeatherIcon: 6,
IsDayTime: true,
Temperature: {
Metric: {
Value: 18.6,
Unit: "C",
UnitType: 17
},
Imperial: {
Value: 66,
Unit: "F",
UnitType: 18
}
},
MobileLink: "http://m.accuweather.com/en/in/kodaikanal/195980/current-weather/195980",
Link: "http://www.accuweather.com/en/in/kodaikanal/195980/current-weather/195980"
}
]
|
|
|
|
|
If you have that in a variable called "data", then this is how you could access it:
var value = data[0]['Temperature']['Metric']['Value'];
Or this way:
var value = data[0].Temperature.Metric.Value;
If you're not certain that these elements exist you should check before trying to access them, otherwise you will get a type error: Cannot read property '...' of undefined .
|
|
|
|
|
Hi,
I have a strange behavior:
I have a collection of shapes that each one of them has a mouseover and mouseout event handlers.
When the user moves across a shape, its color changes and then when he moves out of it, its color returns to the original color.
The thing that I don't understand is sometimes, the mouseout event isn't trigering at all and the color of the shape remains with the hovered state.
Here's a fiddle I created just to demonstrate the problem. The mouseout sometimes doesn't run and so the color doesn't return to its normal red.
jsfiddle.net/aK5Cz
I even tried adding a global variable as the last element hovered and checking it but no luck...
Any ideas?
modified 29-Jun-14 7:44am.
|
|
|
|
|
I think the problem that I can see is that even though addEventListener is called and executed, the handler doesn't execute.
You can see from the console log that it reaches the end of the mouseOver function but never the less the handler doesn't execute.
|
|
|
|
|
You code looks extremely complicated for a simple mouseOver test... I can't see what the logic behind detach/attach the event handler every time. It also possible that because of the complexity of your code it takes too much time to handle one event so the second is wasted (JavaScript is single threaded!!!)...
First check your 'frame' code without complication, than add functionality bit-by-bit to check when problems start to show...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Thanks for your response Peter.
The code that you see is what needs to be there in order for the code to run.
I removed some of the stuff and changed some things but it doesn't matter.
I know that JS is single threaded. Maybe that could be the reason.
I will check it.
|
|
|
|
|
I checked the code - it's the bare minimum I need for the mouse over\out so I don't have a lot to remove - although I removed parts.
http://jsfiddle.net/aK5Cz/3/[^]
What do you mean "I can't see what the logic behind detach/attach the event handler every time". There's no logic behind it - I just remove it. It's a built-in function.
The code sometimes reaches the end of mouseover and doesn't execute the mouseout when the cursor is out.
In case you are right about the thread issue: what are my alternatives?
|
|
|
|
|
ThetaClear wrote: "I can't see what the logic behind detach/attach the event handler every time"
What I see that when you are int the mouseOver you detach it and attach mouseOut, in mouseOut you detach mouseOut and attach mouseOver. Why?! Attach both mouseOver and mouseOut once at the beginning...IMHO that's your main problem. You can see that you miss mouseOut when you move mouse too fast...So the thread can't keep up with you and drops events...
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Ok.
I don't know if you had a chance of working with easeljs library but if I want to change the color of a certain shape i.e. my rectangle, I need to draw another rectangle and give it a different color and give it a handler for the mouseOut.
To do that, I need to remove the previous rectangle.
I can't just attach mouseOver and mouseOut once in the beginning because I'm removing and adding shapes all the time when the user hover on them so I have to add handlers to them.
Now, for your second remark:
Quote: You can see that you miss mouseOut when you move mouse too fast...So the thread can't keep up with you and drops events...
If that is the problem (moving too fast). how can I solve it?
|
|
|
|
|
You have not recreate the shape to change its color, otherwise what use the library has?! Use graphics.beginFill and stage.update in the mouseOver too! Here a very nice sample of it - http://www.createjs.com/#!/EaselJS/demos/dragdrop[^]
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
|
Read OP carefully - it's about changing the color of a shape on a HTML canvas! No CSS for that
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Right, well, this seems to work as requested:
var stage = null;
var sh = new createjs.Shape();
$(document).ready(function(){
var canvas = document.getElementsByTagName("canvas")[0];
var context = canvas.getContext("2d");
stage = new createjs.Stage(canvas);
// main stage surface
stage.enableMouseOver();
drawInitialShape();
});
function drawInitialShape(){
var cont = new createjs.Container();
stage.addChild(cont);
sh.graphics.beginFill('#FF0000').drawRoundRect(0, 0, 20, 20, 1.5);
sh.x = 150;
sh.y = 150;
cont.addChild(sh);
stage.addChild(cont);
sh.addEventListener('mouseover', function(e){
onSeatMouseOver(e);
});
sh.addEventListener('mouseout', function (e) {
onSeatMouseOut(e);
});
stage.update();
}
var onSeatMouseOver = function (e) {
$('body').css('cursor', 'pointer');
sh.graphics.beginFill('#dddddd').drawRoundRect(0, 0, 20, 20, 1.5);
stage.update();
}
var onSeatMouseOut = function (e) {
$('body').css('cursor', 'auto');
sh.graphics.beginFill('#FF0000').drawRoundRect(0, 0, 20, 20, 1.5);
stage.update();
}
modified 20-Oct-19 21:02pm.
|
|
|
|
|
Exactly!
I'm not questioning your powers of observation; I'm merely remarking upon the paradox of asking a masked man who he is. (V)
|
|
|
|
|
Great, it works!!!
Thanks guys!
|
|
|
|