English 中文(简体)
在某些条件下从代码背后的代码上调用java书写功能[复制]
原标题:calling javascript function from code behind under some condition [duplicate]
This question already has answers here:
Closed 11 years ago.

Possible Duplicate:
Calling ASP.NET Code Behind function from Javascript
using javascript function to be called from code behind under specific condition

this is a javascript function.

     function openWinContentTemplate() {
     $find("RadWindow_ContentTemplate").show();
     }

我想将这一javascript功能从纽特被点击的代码上称作:

    protected void button_click()
    {
     if(true)
        //call javascript function here
    }
问题回答

你们可以呼喊。 密码在服务器上,你的笔记在客户上。 在浏览器收到答复时,将《登记册》文本中的“标准”改为“参考”。

你们可以这样做。

页: 1 Js作为在编码背后登记的文字

Page.RegisterStartupScript("key","value")

关键是你想提供文字的用词。

Example

"PageClose"

价值为

stringBuilder str = new StringBuilder()
str.Append("<script = language= javascript >");
str.Append("window.close();");
str.Append("</script>")

页: 1 页: 1

Then use this in the event handler you want to execute the script

Page.RegisterStartUp("PageClose",str.ToString());

这将把 j印放在页末端之前

Page.ClientScriptBlock("PageClose",str.ToString());

这将使联合材料的功能在所投放的页标之后。

希望这一帮助





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签