Topic: problem with countdown timer
cleanentries priority asked 9 months ago
Expected behavior
I have an Asp.Net webforms project with content pages and a single master page. I have 2 content pages at the same level as the masterpage in the folder structure of my project. I have placed markup for the countdown control in the master page. I would expect that any content page that loads would show the countdown timer because it's in the master page.
Actual behavior
When I load content page A I see the countdown timer info. When I load page B the countdown timer info does NOT show and I get an error in Console. I need to know why I get the error for page B and NOT page A.
Resources (screenshots, code snippets etc.)
On the masterpage I have added the countdown markup right before the content placeholder for the body of the content pages as shown below.
<div data-mdb-countdown-init data-mdb-countdown="20 February 2024 23:59:59"
data-mdb-countdown-label-position="horizontal">
<div class="countdown-unit countdown-days" data-mdb-countdown-label="d"></div>
<div class="countdown-unit countdown-hours" data-mdb-countdown-label="h"></div>
<div class="countdown-unit countdown-minutes" data-mdb-countdown-label="m"></div>
<div class="countdown-unit countdown-seconds" data-mdb-countdown-label="s"></div>
</div>
<div class="ms-3 me-3">
<asp:ContentPlaceHolder id="cphBody" runat="server">
</asp:ContentPlaceHolder>
</div>
I have the following 2 tags in the head section of my masterpage:
<link rel="stylesheet" href="css/mdb.min.css" />
<link href="css/countdown.min.css" rel="stylesheet" />
I have the following tags at the bottom of the master page right before the closing html tag:
<script
src="//code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
crossorigin="anonymous"></script>
<script type="text/javascript" src="js/mdb.min.js"></script>
<script type="text/javascript" src="js/countdown.min.js"></script>
Console shows a "Parameter count mismatch" error as shown below:
Uncaught Sys.ParameterCountException: Sys.ParameterCountException: Parameter count mismatch.
String$startsWith ScriptResource.axd:491
startsWith es.string.starts-with.js:29
getDataAttributes manipulator.js:51
getDataAttributes manipulator.js:51
value countdown.js:129
o countdown.js:54
e countdown.js:406
e countdown.js:403
Webpack 4
o
<anonymous>
<anonymous>
<anonymous>
ScriptResource.axd:22:15
Error$create ScriptResource.axd:237
Error$parameterCount ScriptResource.axd:413
Function$_validateParameterCount ScriptResource.axd:118
Function$_validateParams ScriptResource.axd:70
String$startsWith ScriptResource.axd:491
startsWith es.string.starts-with.js:29
getDataAttributes manipulator.js:51
filter self-hosted:241
getDataAttributes manipulator.js:51
value countdown.js:129
o countdown.js:54
e countdown.js:406
forEach self-hosted:203
e countdown.js:403
Webpack 4
And also this error:
Uncaught Sys.ParameterCountException: Sys.ParameterCountException: Parameter count mismatch.
String$startsWith ScriptResource.axd:491
startsWith es.string.starts-with.js:29
Sys$UI$DomEvent ScriptResource.axd:3986
browserHandler ScriptResource.axd:4052
2 ScriptResource.axd:22:15
Error$create ScriptResource.axd:237
Error$parameterCount ScriptResource.axd:413
Function$_validateParameterCount ScriptResource.axd:118
Function$_validateParams ScriptResource.axd:70
String$startsWith ScriptResource.axd:491
startsWith es.string.starts-with.js:29
Sys$UI$DomEvent ScriptResource.axd:3986
browserHandler ScriptResource.axd:4052
Grzegorz Bujański staff answered 9 months ago
This looks like a problem with the way the ASP code works on the server side. I can only guess that the error occurs when the HTML code is run on the server side and the JS code on the client side. The only thing I can recommend is running the countdown plugin on the client side. We don't have enough experience with ASP to know any other solution.
cleanentries priority commented 9 months ago
not sure how I would do that. The scriptmanager has to be on the page and I was trying to use the countdown timer on each row in a repeater.
Grzegorz Bujański staff commented 9 months ago
Unfortunately, we have no experience using scriptmanager and it's hard for me to say how to do it and whether it is even possible. But next.js sometimes encounters issues with server-side code and It is possible to separate the code to be executed on the client side as a separate component. Thanks to this, the code in this component will be executed on the client side, and the remaining page code will be executed on the server side. Maybe ASP can solve it similarly?
cleanentries priority answered 9 months ago
The project is too large for me to be able to include enough for you to get the entire picture of what might be affecting it unfortunately. I believe I found out what might be causing it although I don't know how to fix it. On the page where the timer does NOT work I have an <asp:ScriptManager ID="smScriptMgr" runat="server"></asp:ScriptManager>
tag. So what I did was place this exact tag markup on the page that DOES show the timer and tried to run it. The page that used to work now does NOT work and shows the same error messages as the page that doesn't work. So the ScriptManager tag is causing issues with the countdowntimer control. So what do I do now?
cleanentries priority commented 8 months ago
I have discovered the reason for the issue. Apparently both mdb and scriptmanager try to override the startswith string function. mdb appears to define it with a different number of parameters than scriptmanager is expecting. The way to get around it is to add ScriptMode="Release" to the scriptmanager declaration.
cleanentries priority answered 9 months ago
.Net Framework 4.8. The MDB version is right in the ticket info on the right side of this page. Here it is: User: Priority Premium support: Yes Technology: MDB Standard MDB Version: MDB5 6.4.2 Device: PC Browser: Firefox OS: Windows 10 Provided sample code: No Provided link: No
Grzegorz Bujański staff commented 9 months ago
I created a new project and tested it. Unfortunately, I am unable to reproduce this error. Please send the project in which I will be able to reproduce this error to the email address support@mdbootstrap.com.
Grzegorz Bujański staff answered 9 months ago
Script tags should be right before the closing body
tag, not html
. But I don't think this is the reason for this error. What version of .NET are you using? Additionally, please specify what version of MDB you are using? The code in the snippets suggests that you are using MDB version 7, but the name of the imported JS file and what you marked in the issue details suggest that you are using version 6.
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Priority
- Premium support: Yes
- Technology: MDB Standard
- MDB Version: MDB5 6.4.2
- Device: PC
- Browser: Firefox
- OS: Windows 10
- Provided sample code: No
- Provided link: No