繁体   English   中英

未捕获的ReferenceError:未定义显示值(仅适用于移动设备)

[英]Uncaught ReferenceError: show value is not defined(Only for mobile device)

嗨,我已经实现了一个代码,在该代码中添加到购物车的项目得到添加,还有一个弹出窗口打开,显示购物车项目。 在桌面上它运行良好,但在移动设备上它不工作。 对于移动设备来说,这是错误的

Uncaught ReferenceError: showvalue is not defined

这是我的下面的代码

<script type="text/javascript">  
function showvalue(value, product) {

    $('#<%= lblproduct1.ClientID %>').text(product);
    $('#<%= lblVessel.ClientID %>').text(value);
    $('.cart_popup').show();
    setTimeout(function () {
        $('.cart_popup').fadeOut('slow');
    }, 5000);
    return false;
}
function Showprogress() {               
    $('#<%= Progress.ClientID %>').show();      
 }

.ascx页面上的Html侧面

<asp:Button ID="AddToBasketButton" OnClientClick="Showprogress()" runat="server" OnClick="AddToBasketButton_Click" EnableViewState="false" ValidationGroup="AddToBasket" Text="Add to Cart" />

我的.cs边码(传递总数和产品数量)

ScriptManager.RegisterClientScriptBlock(this.Page, typeof(UpdatePanel), UniqueID, "showvalue('" + Total + "','" + productquantity + "');", true);

我只面临移动设备的问题。 点击按钮我的页面刷新,弹出窗口没有打开

我删除了jquery弹出窗口并使用了Ajax Modal弹出窗口。 弹出窗口打开正常,因为我从.cs方面调用它,但是在5秒后它自动隐藏它在那种情况下不能正常工作我使用了下面的代码。

<asp:Button ID="AddToBasketButton"  OnClientClick="Showprogress();" runat="server" OnClick="_Click" Text="button" />//button click and onclient click 
//Below div is only showing processing image :-)
<div id="Progress" runat="server" style="display: none;">
<img src="../images/spinner.gif" />
</div>

我的剧本

<script type="text/javascript">
$(document).ready(function () { hide_pop(); });

function Showprogress() {       
    $('#<%= Progress.ClientID %>').show();
    hide_pop();
    return false;
}
function hide_pop() {
    setTimeout(function () {
        $('.popup_cart_main').fadeOut('slow');//Popup Panel class
        $('.modalBackground').fadeOut('slow');//Background blacklayout Class
    }, 5000);       
    return false;
}

Modalpopup

<asp:LinkButton ID="lnkDummy" runat="server" ></asp:LinkButton>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" BehaviorID="mpe" runat="server"
PopupControlID="pnlPopup" TargetControlID="lnkDummy" BackgroundCssClass="modalBackground" >
</cc1:ModalPopupExtender>
<asp:Panel ID="pnlPopup" runat="server" CssClass="popup_cart_main" Style="display: none">
<div class="cart_popup" >               
      Solved         
        </div>
 </asp:Panel>

此代码适用于所有浏览器和所有移动设备,包括iphone和Android

我也认为(根据实际问题)如果我没有删除jquery弹出窗口并且只放在代码下面我的弹出窗口也开始在移动设备上工作

 $(document).ready(function () { showvalue (); });// based on actual question

确保在调用RegisterClientScriptBlock之前呈现脚本。 HTML解析是线性的。

  • 您是否错过了复制结束标记,或者您也没有在代码中执行此操作?

它应该是:

<script type="text/javascript">  
function showvalue(value, product) {

    $('#<%= lblproduct1.ClientID %>').text(product);
    $('#<%= lblVessel.ClientID %>').text(value);
    $('.cart_popup').show();
    setTimeout(function () {
        $('.cart_popup').fadeOut('slow');
    }, 5000);
    return false;
}
function Showprogress() {               
    $('#<%= Progress.ClientID %>').show();      
 }
</script>
  • 尝试另一种方法:

在javascript中:

<script type="text/javascript"> var jName = '<%=cName()%>'</script>

在c#中:

protected string cName() {
    return "examplevarcontent";
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM