如何在内容页面中运行Java脚本功能 [英] How to run Java script function in content page

查看:98
本文介绍了如何在内容页面中运行Java脚本功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

先生,

我想在内容页面中运行java脚本功能,我使用下面的代码。



 <%@       标题  =    语言  =  C#    MasterPageFile   = 〜/ newmobi.master    AutoEventWireup   =  true < span class =code-attribute>   CodeFile   =  Default10.aspx.cs   继承  =  Default10   %>  

< asp:Content ID = Content1 ContentPlaceHolderID = head Runat = 服务器 >


< asp:内容 ID = Content2 ContentPlaceHolderID = ContentPlaceHolder1 Runat = 服务器 >
< asp:Panel ID = Panel1 runat = server >
< asp:Image ID = img1 runat = server 高度 = 75px

< span class =code-attribute> ImageUrl = 〜/ images / User-icon.png 宽度 = < span class =code-keyword> 75px onmouseover = document.getElementById('lnkbtn2')。style.display ='block' ;

< span class =code-attribute> onmouseout = document.getElementById('lnkbtn2')。style.display ='none'; / >
< ; asp:LinkBut​​ton ID = lnkbtn2 runat = server style = display:none; onmouseover = document.getElementById('lnkbtn2')。style.display ='block';

onmouseout = document.getElementById('lnkbtn2')。style.display ='无'; > 更改个人资料照片





但它在这个页面中不起作用,

但是在其他aspx页面上工作(没有master.aspx相关页面)。

请帮助我。

解决方案

尝试使用控件的clientid属性。当您拥有母版页时,您的控件将无法通过您为此编写的相同ID进行识别。





使用



 onmouseover =   document.getElementById('<%= lnkbtn2.ClientID%>')。style.display ='block ; 


Sir,
I want to run java script function in content page,i;m using below code.

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

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


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:Panel ID="Panel1" runat="server">
       <asp:Image ID="img1" runat="server" Height="75px" 

            ImageUrl="~/images/User-icon.png" Width="75px"  onmouseover="document.getElementById('lnkbtn2').style.display = 'block';"

             onmouseout="document.getElementById('lnkbtn2').style.display = 'none';"/>
        <asp:LinkButton ID="lnkbtn2" runat="server" style="display:none;" onmouseover="document.getElementById('lnkbtn2').style.display = 'block';"

             onmouseout="document.getElementById('lnkbtn2').style.display = 'none';">Change Profile pic



but it's not work in this page,
but work in other aspx page (without master.aspx related page).
please help me.

解决方案

try and use clientid property of the control. when you have a master page your control will not recognize by the same id that you write for this.


use

onmouseover="document.getElementById('<%=lnkbtn2.ClientID%>').style.display = 'block';"


这篇关于如何在内容页面中运行Java脚本功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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