I need to show a pop up window based on the Text property of a button?
I set the btnBoxScore.Text in
RowDataBound
I have tried something like the below, but is giving jquery/javascript errors:
Is there any way to do this?
function ShowBoxScorePopUp(sender) {
var theHtml;
$(document).ready(function () {
$('.dummyClass').click(function () {
theHtml = $(this).html();
// alert(theHtml);
});
});
if (theHtml.indexOf("Makeup Game") >= 0) {
popupBoxScore.Show();
}
}
CommandArgument='<%#Eval("GAME_ID") + "_" + Eval("ID").ToString()%>'
CommandName="btnBoxScoreCN">Error:
Line: 39
Error: Unable to get value of the property 'indexOf': object is null or undefined
Keep in mind, with your code the variable theHtml is only going to be valid after you click the button. Your ShowBoxScorePopup function is only wiring up the click event, then trying to check your theHtml variable which isn't going to be set when you call
this function because no click event has happened since the dummyClass has had it's click event wired up.
Try moving your check for indexOf within the click handler for your dummyclass.
markfitzme
Keep in mind, with your code the variable theHtml is only going to be valid after you click the button. Your ShowBoxScorePopup function is only wiring up the click event, then trying to check your theHtml variable which isn't going to be set when you call
this function because no click event has happened since the dummyClass has had it's click event wired up.Try moving your check for indexOf within the click handler for your dummyclass.
Thanks for the help. That was the issue.
Here is the good code:
function ShowBoxScorePopUp() {
$(document).ready(function () {
$('.dummyClass').click(function () {
var theHtml = $(this).html();
if (theHtml.indexOf("Makeup Game") >= 0) {
popupBoxScore.Show();
}
});
});
}
One more question: Is there a better way to check the Text property of the button compared to pull all the html?
沒有留言:
張貼留言