将多个eval参数传递给ASPX中的javascript函数 [英] Passing multiple eval parameters to a javascript function from ASPX

查看:209
本文介绍了将多个eval参数传递给ASPX中的javascript函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我已经知道它如何使用单个参数。可以使用两个参数。



我尝试过:



Hi All,
I already know how it works with a single parameter.Is it possible with two parameters.

What I have tried:

OnClientClick='<%# Eval("psid", "window.open(\"add.aspx?cid={0}\", null,\"scrollbars=yes,top=10,left=10\", \"true\");") %>'





一个参数是文本框值。提前谢谢



One parameter is a textbox value.Thanks in advance

推荐答案

从你的代码看,你看起来并没有将值传递给任何函数,所以我担心这是不可能的,虽然我不是Javascript中的PRO。

但是,你可以随时传递所需数量的参数使用 Eval 的函数。



在这种情况下,你的代码应该类似于以下内容 -

From your code it looks you are not exactly passing values to any function, so I afraid that's not possible, although I am not a PRO in Javascript.
However, you can always pass as many parameters required to a function using Eval.

In that case, your code should look something like following-
OnClientClick='<%# "MyFunctionName(" +Eval("FirstParameter") + ","+Eval("SecondParameter")+" );" %>'





看起来你想要打开一个新窗口,你可以在里面写功能也很好。



如果不清楚或需要进一步的帮助,请告诉我。



谢谢:)



It looks like you want to open a new window as well, which you can write inside the function as well.

Please let me know if something is not clear or if you need further help.

Thanks :)


通过两个参数如



Pass two params like

add.aspx?param1=123&param2=456





但是如果第二个参数需要是文本框的值,你可能最好不要使用OnClientClick而是纯javascript在页面上。你需要像





However if the second parameter needs to be the value of a textbox you're probably better not using OnClientClick but pure javascript on the page. You'll need something like

<asp:TextBox ID="TextBox1" runat="server" />
<asp:Button runat="server" ID="btn" OnClientClick='<%# string.Format("window.open(\"add.aspx?cid={0}&param2=\" + document.getElementById(\"{1}\").value, null,\"scrollbars=yes,top=10,left=10\", \"true\");", Eval("psid"), Container.FindControl("TextBox1").ClientID) %>' Text="click"/>





如何找到文本框以获取其ID取决于文本框的位置和文本框的类型,这两者都不是你所说的。



How you find the textbox to get its id depends where the textbox is though and what kind of textbox it is, neither of which you've said.


这篇关于将多个eval参数传递给ASPX中的javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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