如何在ASP.Net中使用C#调用一些JavaScript代码? [英] How can I call some JavaScript codes using C# in ASP.Net ?

查看:65
本文介绍了如何在ASP.Net中使用C#调用一些JavaScript代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:)

我的源代码中有此代码,使用Telerik来显示radwindow

Hi all :)

I have this code in my source, using Telerik to show a radwindow

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Tests_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <telerik:RadScriptManager ID="RadScriptManager1"  runat="server">
        
        <telerik:RadFormDecorator ID="RadFormDecorator1"  runat="server" />
        <telerik:RadWindowManager ID="RadWindowManager1"  runat="server">
            <windows>
                <telerik:RadWindow ID="GetContactUsWindow"  runat="server" Title="ContactUS" Modal="true"

                    NavigateUrl="Default2.aspx" ReloadOnShow="true">
                
            </windows>
        
        <br />
        <asp:ImageMap ID="ImageMap1" runat="server" 

            ImageUrl="~/Pic's/General/Final PNG3.PNG">
            <asp:CircleHotSpot AlternateText="ContactUs" PostBackValue="$find('<%= GetContactUsWindow.ClientID%>').show();return false;"

                Radius="29" X="717" Y="570" />
        
    </div>
    </form>
</body>
</html>




我尝试调用此窗口,将其放在此处的调用方式

PostBackValue ="$ find(''<%= GetContactUsWindow.ClientID%>'')).show();返回false;

我想使用此C#代码进行调用




and I try to call this window that I put it''s call way here

PostBackValue="$find(''<%= GetContactUsWindow.ClientID%>'').show();return false;

I want to call it using this C# code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Tests_Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ImageMap1_Click(object sender, ImageMapEventArgs e)
    {
        if(e.PostBackValue.Contains("ContactUs"))
        {
           // e.PostBackValue = GetContactUsWindow.ClientID;
        }
    }
}



你能帮我吗?

有什么办法可以做这样的事情吗?


谢谢大家:)



can you please help me ?

is there any way to do such thing like this ?


thank you all :)

推荐答案

find('<% = GetContactUsWindow.ClientID %> ').show();返回false;" span> 半径 29" X =" Y =" / < /div > < /form > < /body > < /html >
find('<%= GetContactUsWindow.ClientID%>').show();return false;" Radius="29" X="717" Y="570" /> </div> </form> </body> </html>




我尝试调用此窗口,将其放在此处的调用方式

PostBackValue ="




and I try to call this window that I put it''s call way here

PostBackValue="


find(''<%= GetContactUsWindow.ClientID%>'').show();返回false;

我想使用此C#代码进行调用

find(''<%= GetContactUsWindow.ClientID%>'').show();return false;

I want to call it using this C# code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Tests_Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void ImageMap1_Click(object sender, ImageMapEventArgs e)
    {
        if(e.PostBackValue.Contains("ContactUs"))
        {
           // e.PostBackValue = GetContactUsWindow.ClientID;
        }
    }
}



你能帮我吗?

有什么办法可以做这样的事情吗?


谢谢大家:)



can you please help me ?

is there any way to do such thing like this ?


thank you all :)



我们无法通过使用服务器事件来调用客户端功能.就像我们无法通过onclick属性调用javascript函数一样,我们只能通过clientclick属性调用它

现在我希望你能理解我的意思.

但是有一种方法可以在您的情况下调用客户端功能

检查此行可以为您提供帮助

Hi
we cannot invoke client functions by using server events. like we cannot invoke javascript function by onclick property we just invoke it by clientclick property only

now i hope you understand what i mean .

but there is a way to invoke client function in your case

check this line it can helps you

<asp:imagemap id="ImageMap1" runat="server" xmlns:asp="#unknown">
            ImageUrl="~/Images/Sunset.jpg">
            <asp:circlehotspot alternatetext="ContactUs" navigateurl="javascript:alert('dffdfdf');">
                Radius="29" X="100" Y="100" />
        
        </asp:circlehotspot></asp:imagemap> 




编写您的JavaScript代码而不是alert(),这样您就可以随意运行

一切顺利




write your javascript code instead of alert() thn it works as you like

all the best


这篇关于如何在ASP.Net中使用C#调用一些JavaScript代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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