|
I have a Web user control with its Javascript code in a JS file. Here is the code in the JS File.
function CtrlColor() {}
CtrlColor.prototype = {
Change: function() {
if (Category == '1') {
this.pnlSearchClientID.style.backGroundColor = 'Red';
} else {
this.pnlSearchClientID.style.backGroundColor = 'Blue';
}
}
};
The User Control has a Panel whose color i want to change from a Page. Here is the User Control:
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="CtrlName.ascx.vb" Inherits="MultiInstanceControl.CtrlName" %>
<asp:Panel ID="pnlSearch" runat="server" Style="background-color: yellow;width: 30px;height: 30px;"></asp:Panel>
<script type="text/javascript" src="CtrlNameJS.js"></script>
<script type="text/javascript">
function CtrlName <%= me.ClientID %> () {
this.pnlSearchClientID = <%= pnlSearch.ClientID %> ;
}
CtrlName <%= me.ClientID %> = CtrlColor.prototype;
</script>
Category is a Server Side property of the Web Control, which I set in the Markup of the page.
In the Page I have 2 Instances of the above Web user Control.
<form id="form1" runat="server">
<div> 1. First Instance
<uc1:CtrlName ID="CtrlName1" IsMultipleFile="false" Category="1" runat="server" />
<asp:Button runat="server" ID="btnTest1" Text="Get Value" OnClientClick="return btnTest_ClientClick('1');" />
<br /> 2. Second Instance
<uc1:CtrlName ID="CtrlName2" IsMultipleFile="false" Category="2" runat="server" />
<asp:Button runat="server" ID="Button2" Text="Get Value" OnClientClick="return btnTest_ClientClick('2');" />
</div>
<script type="text/javascript">
var inst1 = null;
var inst2 = null;
inst1 = new CtrlName<%= CtrlName1.ClientID %> ();
inst2 = new CtrlName<%= CtrlName2.ClientID %> ();
function btnTest_ClientClick(strVal) {
if (strVal == '1') {
inst1.Change();
} else {
inst2.Change();
}
return false;
}
</script>
</form>
When I execute this, it throws an error:
CtrlNameCtrlName1 is not a constructor
at this line
inst1 = new CtrlName<%=CtrlName1.ClientID %>();
Any suggestion where I am going wrong?
|
|
|
|
|
HemeshSoni wrote: function CtrlName <%= me.ClientID %> ()
Have you really got the space in there, or was that a typo in your question?
HemeshSoni wrote: CtrlName <%= me.ClientID %> = CtrlColor.prototype;
Again with the space. And shouldn't you be assigning the prototype, rather than overwriting the function?
CtrlName<%= me.ClientID %>.prototype = CtrlColor.prototype;
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes it was a typing mistake, there is no space between the
CtrlName<%= me.ClientID %>
|
|
|
|
|
Thank you Richard, it worked.
|
|
|
|
|
Hy,
I am one of those who have problems with url. I have mvc app with angular. It works on VS and on IIS on 5577 port, but on 80 port doesn`t. Why?
I got 404 in console that url based on adress/control/function is not found. Isn`t this problem with url routing? I still cant get out of it. I did aspnetregiis command, which was succesfull and inserted
runAllManagedModulesForAllRequests="true"
in config file.
Still not working. any ideas? There is static file handler in IIS. Should it be removed?
|
|
|
|
|
Are you using OWIN?
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
As far as I see, OWIN is only in my config file where it was automaticaly created. I don`t use it directly anywhere.
|
|
|
|
|
It works on a different port, so that wouldn't have mattered. I blame Monday-morning brain and apologize.
It sounds like you have this problem:
iis 7 - ASP.NET Web API application gives 404 when deployed at IIS 7 - Stack Overflow
There are a number of possible solutions in there, though I've always preferred the specific handler vs the runAll... method.
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
|
Created a loop to loop through an array based on the values from the dice roll. Trying to get all the possible scores for a yahtzee game. so far I have it working to that it does add the scores based on the roll example1
I also have it working so that it does not continue to add the score if the a certain die is selected
However my issue is that it keeps increasing the score instead of starting over on subsequent rolls example2
<pre>$(document).ready(function(){
var die1=$('.die1');
var die2=$('.die2');
var die3=$('.die3');
var die4=$('.die4');
var die5=$('.die5');
var turns=3;
var dice;
var dice_value = new Array(5);
var ones=0;
var twos=0;
var threes=0;
var fours=0;
var fives=0;
var sixes=0;
var die;
function roll(die,i){
rando = Math.floor(Math.random()*6)+1;
die.html("<img src=images/die"+rando+".png>");
die.find('img').attr('class', rando);
dice_value[i]=rando;
$('img').height(50);
};
$('.die').click(function(){
$(this).toggleClass('selected');
});
$('.button').click(function(){
for(i=0; i<=turns; turns--){
if(turns>0){
dice =[die1,die2,die3,die4,die5];
for(i=0; i<dice.length;i++){
if (!dice[i].hasClass('selected')){
roll(dice[i],i);
die= dice[i].find('img').attr('class');
}
}
}
else{
$('.warning').html('Pick a category!');
}
}
for(var i=0; i< dice_value.length;i++){
if(!dice[i].hasClass('selected') && turns > 0){
if( dice_value[i] == 1){
ones= ones+1;
$('.aceScore').html(ones);
}
if( dice_value[i] == 2){
twos= twos+2;
$('.twoScore').html(twos);
}
if( dice_value[i] == 3){
threes= threes+3;
$('.threeScore').html(threes);
}
if( dice_value[i] == 4){
fours= fours+4;
$('.fourScore').html(fours);
}
if( dice_value[i] == 5){
fives= fives+5;
$('.fiveScore').html(fives);
}
if( dice_value[i] == 6){
sixes= sixes+6;
$('.sixScore').html(sixes);
}
}
}
});
console.log(ones);
console.log(twos);
console.log(threes);
console.log(fours);
console.log(fives);
console.log(sixes);
});
<pre lang="HTML"><pre><table border="1" height='200' >
<tr>
<th colspan="3">Upper Section</th>
</tr>
<tr>
<td>Aces</td>
<td>Sum of all the ones</td>
<td class="score aceScore"></td>
</tr>
<tr>
<td>Twos</td>
<td>Sum of all the twos</td>
<td class="score twoScore"></td>
</tr>
<tr>
<td>Threes</td>
<td>Sum of all the threes</td>
<td class="score threeScore"></td>
</tr>
<tr>
<td>Fours</td>
<td>Sum of all the fours</td>
<td class="score fourScore"></td>
</tr>
<tr>
<td>Fives</td>
<td>Sum of all the fives</td>
<td class="score fiveScore"></td>
</tr>
<tr>
<td>Sixes</td>
<td>Sum of all the sixes</td>
<td class="score sixScore"></td>
</tr>
<tr>
<td colspan ='2'>Total</td>
<td class="totalScore"></td>
</tr>
<tr>
<td>Bonus</td>
<td>Score 35 </td>
<td class="bonus"></td>
</tr>
<tr>
<td colspan ='2'>Upper Total</td>
<td class="upperScore"></td>
</tr>
<tr>
<th colspan="3">Lower Section</th>
</tr>
<tr>
<td>3 of a Kind</td>
<td>SUm of all dice</td>
<td class="three_of_kind"></td>
</tr>
<tr>
<td>4 of a kind</td>
<td>Sum of all dice</td>
<td class="four_of_kind"></td>
</tr>
<tr>
<td>Full House</td>
<td>Score 35</td>
<td class="fullhouse"></td>
</tr>
<tr>
<td>sm. straight</td>
<td>Score 30</td>
<td class="sm"></td>
</tr>
<tr>
<td>lg. Straight</td>
<td>score 40</td>
<td class="lg"></td>
</tr>
<tr>
<td>Yahtzee</td>
<td>Score yatzee</td>
<td class="yatzee"></td>
</tr>
<tr>
<td>Chance</td>
<td>sum of all dice</td>
<td class="chance"></td>
</tr>
<tr>
<td colspan ='2'>Lower Total</td>
<td class="lowerScore"></td>
</tr>
<tr>
<td colspan ='2'>Upper Total</td>
<td class="UpperScore"></td>
</tr>
<tr>
<td colspan ='2'>Combined Total</td>
<td class="combinedScore"></td>
</tr>
<section class="dice">
<div class="die die1"></div>
<div class="die die2"></div>
<div class="die die3"></div>
<div class="die die4"></div>
<div class="die die5"></div>
</section>
<button class="button">ROll</button>
</table>
</div> <!-- board div -->
</body>
</html>
|
|
|
|
|
You just need to reset all the counters to zero before each throw.
|
|
|
|
|
when i do that i doesnt add the score to the dice that I have selected to keep.
|
|
|
|
|
Then you need to keep those scores separately also. Think about how you actually play Yahtzee, and what you need to do before and after each throw.
|
|
|
|
|
$(document).ready(function () {
debugger;
if (window.location.href.toLowerCase = "https: Pages/HomePage.aspx") {
test.makeSharePointReady1();
}
I am trying to redirect to another site (say www.google.com) from a SharePoint site.
|
|
|
|
|
A very simple and quick fix will be to change the = operator, to == operator.
if (window.location.href.toLowerCase == "https: Pages/HomePage.aspx") {
"=" is used to assign the value, and "==" is used to test equality. Also, once converted to lowerCase, there is no sense in having "Page/HomePage" in caps, they will also be in lower format. Anyways, just see if that works otherwise, change them to lower case as well.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
|
toLowerCase is also a method so you need (). Also, lowercase your text that you are comparing to.
if (window.location.href.toLowerCase() == "https://pages/homepage.aspx") {
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.
modified 10-Feb-17 11:05am.
|
|
|
|
|
Except that a lower-case string will never be equal to a string that contains upper-case characters.
Also, the protocol is missing the "//", and the server name is missing.
But apart from that...
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: Except that a lower-case string will never be equal to a string that contains upper-case characters. Ya, I didn't get that far into it. I had read the previous answer and noticed they missed that point. I guess I should have kept on looking.
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.
|
|
|
|
|
exactly
|
|
|
|
|
The location.href will return the full URL, including the server name. The string you're trying to compare it to does not contain the server name, and is missing the "//" from the protocol. Even if you make that string lower-case, it's never going to match the full URL.
Assuming you only want to match the path, use the pathname property instead of the href property:
if (window.location.pathname.toLowerCase() == "/pages/homepage.aspx") {
...
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I don't know where the crap characters before the full names are coming from...
1211;#Doe Doe, John;#1238;#Doe, John
Can someone show the code on how to clean or ltrim then separate each full name with semi-colon
This is part of the code to show the names where "employee" = full name.
Var employee = "";
if (ListName == "Award - Unit")
{
employee = rows[i].getAttribute('Nominee');
};
str+='<tr><td class=leftcol valign=top><font size="+2">Employee</font></td><td class=rightcol><font size="+2">' + employee + '</font></td></tr>';
|
|
|
|
|
|
is the data coming from sharepoint?
|
|
|
|
|
I'm thinking of using the browser BSON parser with a custom OWIN middleware that will pass queries directly to a Mongo instance for searches, and to WebAPI for processing.
Does anyone have any experience using this as a data transmission system? Primarily I'm curious as to any serious pitfalls that I might be overlooking, particularly with the browser BSON parser.
Edit: This guy GitHub - mongodb/js-bson: BSON Parser for node and browser
"There are three kinds of lies: lies, damned lies and statistics."
- Benjamin Disraeli
|
|
|
|
|
I'm trying to auto populate the value of a retirement date field by using a DOB (date of birth) value and adding 66 years onto this value.
but it's not working at the moment.
it's just returning the same value as the DOB (so not adding 66 on to it).
here's a fiddle
$( function doDates() {
$("#dateStart").datepicker({
minDate: '-55Y',
changeMonth: true,
changeYear: true,
maxDate: '+3M',
dateFormat: "dd/mm/yy",
onSelect: function (dateStr) {
var min = $(this).datepicker('getDate');
$("#dateEnd").datepicker('option', 'minDate', min || '0');
}
});
$("#dob").datepicker({
minDate: '-55Y',
changeMonth: true,
changeYear: true,
maxDate: '+3M',
dateFormat: "dd/mm/yy",
onSelect: function (dateStr) {
var min = $(this).datepicker('getDate');
$("#dob").datepicker('option', 'minDate', min || '0');
var startDob = $("#dob").datepicker("getDate");
var endDob = new Date();
var daysOld = (endDob - startDob) / (1000 * 60 * 60 * 24);
var retDate = startDob + 66;
$("#diffDaysOld").val(daysOld);
var yearsOld = daysOld / 365.25;
$("#age").val(yearsOld);
$("#dateEnd").val(retDate);
}
});
} );
I've tried both:
var retDate = startDob + 66;
and
var retDate = startDob + (66000 * 60 * 60 * 24);
|
|
|
|