在内容页面中无法使用javascript [英] In content page not working javascript

查看:97
本文介绍了在内容页面中无法使用javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage2.master" AutoEventWireup="true" CodeFile="OtherSourceIncome_1.aspx.cs" Inherits="OtherSourceIncome" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <br />

推荐答案

首先

First of all

<title></title>
<script type = "text/javascript">
<html xmlns="http://www.w3.org/1999/xhtml">



上面的代码未在子页面中使用.这些标记已在masterpage中使用.因此现在不使用.

检查以下javascript代码:



the above code is not used in child page. these tags are already used in masterpage.hence not to be used now.

check with below code of javascript:

<script type = "text/javascript" language="javascript" >


//This is the javascript function which will calulate the total
function calculate() {

var sub1 = document.getElementById('<%=txtOSIInterstFromBank.ClientID%>').value; // 
alert(sub1);
}

</script>



之所以使用它,是因为在Contentplace Holder中控件的ID发生了变化.为了更好地理解,请查看浏览器的源代码,然后查看控件的ID.

如果得到答案就不要忘了给它评分..

谢谢

Ashish



use this, because in contentplace holder the id of the control change.for better understanding, go to view source of browser, then see the id of your controls.

make it solution if you got your answer and dont forget to rate..

Thanks

Ashish


使用JavaScript调试器(例如Firebug或Chrome)逐步检查功能,找出问题所在.

我*怀疑*是因为您正在使用的母版页将破坏"您的控件ID,所以txtOSIInterestFromDebent会变成cph_100_txtOSIInterestFromDebent或类似的东西.

看一下这篇文章.

母版页和JavaScript document.getElementById [
Use a javascript debugger such as Firebug or Chrome to step through your function and figure out what the problem is.

I *suspect* it''s because you''re using a Master page which will ''mangle'' your control ID''s, so txtOSIInterestFromDebent would become cph_100_txtOSIInterestFromDebent or something similar.

Have a look at this article.

Master Pages and JavaScript document.getElementById[^]

If it''s not this, please provide more info on what ''its not working'' means


这篇关于在内容页面中无法使用javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆