RegisterStartupScript问题。 [英] RegisterStartupScript Question.

查看:41
本文介绍了RegisterStartupScript问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用this.RegisterStartupScript向页面加载时运行的一些javascript和

aspx页面添加。有谁知道这个

函数是否仅适用于Page_Load函数?或者我可以把它放在任何地方。

现在它位于在

" CheckChanged"上调用的eventhandler函数内部。复选框的事件,但它似乎永远不会将javascript

代码添加到页面。还有另一种方法吗?让我解释一下

问题:


我有一个带有一堆复选框的页面。每个复选框强制回发。

在CheckChanged的eventhandler函数中。复选框的事件

我需要确定两个值是否相互匹配。如果他们这样做,那么我想要

使用一些javascript打开一个模态对话框,允许输入两个

的新值。合理?任何帮助都会很棒!谢谢。


- Bill Jones

I''m trying to use this.RegisterStartupScript to add some javascript to and
aspx page that will run when the page is loaded. Does anyone know if this
function only works in the Page_Load function? Or can I put it anywhere.
Right now it is inside the eventhandler function that is called on the
"CheckChanged" event of a checkbox, but it never seems to add the javascript
code to the page. Is there another way to do this? Let me explain the
problem:

I have a page with a bunch of checkboxes. Each checkbox forces a postback.
In the eventhandler function for the "CheckChanged" event of the checkboxes
I need to determine if two values match each other. If they do, then I want
to use some javascript to open a modal dialog to allow for the input of two
new values. Make sense? Any help would be great! Thanks.

- Bill Jones

推荐答案

Bill Jones写道:
Bill Jones wrote:
我正在尝试使用this.RegisterStartupScript将一些javascript添加到页面加载时运行的aspx页面。有谁知道这个
函数是否仅适用于Page_Load函数?或者我可以把它放在任何地方。
现在它位于在事件处理程序函数内部,在
CheckChanged上调用。复选框的事件,但它似乎永远不会将javascript
代码添加到页面。还有另一种方法吗?让我解释一下
问题:

我有一个带有一堆复选框的页面。每个复选框强制回发。
在CheckChanged的事件处理程序函数中。复选框的事件
我需要确定两个值是否相互匹配。如果他们这样做,那么我希望
使用一些javascript来打开一个模态对话框,以允许输入两个新的值。合理?任何帮助都会很棒!谢谢。

- 比尔琼斯
I''m trying to use this.RegisterStartupScript to add some javascript to and
aspx page that will run when the page is loaded. Does anyone know if this
function only works in the Page_Load function? Or can I put it anywhere.
Right now it is inside the eventhandler function that is called on the
"CheckChanged" event of a checkbox, but it never seems to add the javascript
code to the page. Is there another way to do this? Let me explain the
problem:

I have a page with a bunch of checkboxes. Each checkbox forces a postback.
In the eventhandler function for the "CheckChanged" event of the checkboxes
I need to determine if two values match each other. If they do, then I want
to use some javascript to open a modal dialog to allow for the input of two
new values. Make sense? Any help would be great! Thanks.

- Bill Jones




是的,你可以在代码隐藏的任何地方使用它;它将被添加到

响应输出中。你是积极的活动正在运行,你有没有?b $ b步调通过调试模式?


-

Craig Deelsnyder

Microsoft MVP - ASP / ASP.NET



Yes, you can use it anywhere in code-behind; it will get added to the
response output. Are you positive the event is being run, have you
stepped thru in debug mode?

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


Bill Jones写道:
Bill Jones wrote:
我是尝试使用this.RegisterStartupScript将一些javascript添加到页面加载时运行的aspx页面。有谁知道这个
函数是否仅适用于Page_Load函数?或者我可以把它放在任何地方。
现在它位于在事件处理程序函数内部,在
CheckChanged上调用。复选框的事件,但它似乎永远不会将javascript
代码添加到页面。还有另一种方法吗?让我解释一下
问题:

我有一个带有一堆复选框的页面。每个复选框强制回发。
在CheckChanged的事件处理程序函数中。复选框的事件
我需要确定两个值是否相互匹配。如果他们这样做,那么我希望
使用一些javascript来打开一个模态对话框,以允许输入两个新的值。合理?任何帮助都会很棒!谢谢。

- 比尔琼斯
I''m trying to use this.RegisterStartupScript to add some javascript to and
aspx page that will run when the page is loaded. Does anyone know if this
function only works in the Page_Load function? Or can I put it anywhere.
Right now it is inside the eventhandler function that is called on the
"CheckChanged" event of a checkbox, but it never seems to add the javascript
code to the page. Is there another way to do this? Let me explain the
problem:

I have a page with a bunch of checkboxes. Each checkbox forces a postback.
In the eventhandler function for the "CheckChanged" event of the checkboxes
I need to determine if two values match each other. If they do, then I want
to use some javascript to open a modal dialog to allow for the input of two
new values. Make sense? Any help would be great! Thanks.

- Bill Jones




是的,你可以在代码隐藏的任何地方使用它;它将被添加到

响应输出中。你是积极的活动正在运行,你有没有?b $ b步调通过调试模式?


-

Craig Deelsnyder

Microsoft MVP - ASP / ASP.NET



Yes, you can use it anywhere in code-behind; it will get added to the
response output. Are you positive the event is being run, have you
stepped thru in debug mode?

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET


Bill,


您的复选框控件是否设置为RUNAT =服务器?是否AutoPostBack = True?


您可以将它放在任何地方。在你的CheckChanged事件子中,你可以把:


Dim sb As New System.Text.StringBuilder

sb.Append("< script language = ''javascript''>")

sb.Append(" window.open(''mypage.aspx'',''help'',''width = 400,height = 400,左= 100,t

op = 100,toolbars = no,status = no,scrollbars = yes,resiza ble = yes'');")

sb.Append("< / script>")

RegisterStartupScript(" stp",sb.ToString)


或您的代码是什么你用来打开一个模态对话框,上面打开了

a窗口,但它只是一个例子


HTH,


Raymond Lewallen


" Bill Jones" < WJ **** @ actcci.com>在消息中写道

新闻:#K ************** @ TK2MSFTNGP10.phx.gbl ...
Bill,

Is your checkbox control set to runat=server? Is the AutoPostBack=True?

You can put this anywhere. In your CheckChanged event sub, you can put:

Dim sb As New System.Text.StringBuilder
sb.Append("<script language=''javascript''>")
sb.Append("window.open(''mypage.aspx'',''help'',''width =400,height=400,left=100,t
op=100,toolbars=no,status=no,scrollbars=yes,resiza ble=yes'');")
sb.Append("</script>")
RegisterStartupScript("stp", sb.ToString)

or whatever your code is your using to open a modal dialog, the above opens
a window, but its just an example

HTH,

Raymond Lewallen

"Bill Jones" <wj****@actcci.com> wrote in message
news:#K**************@TK2MSFTNGP10.phx.gbl...
我是尝试使用this.RegisterStartupScript将一些javascript添加到页面加载时运行的aspx页面。有谁知道这个
函数是否仅适用于Page_Load函数?或者我可以把它放在任何地方。
现在它位于在事件处理程序函数内部,在
CheckChanged上调用。复选框的事件,但它似乎永远不会将
javascript代码添加到页面。还有另一种方法吗?让我解释一下
问题:

我有一个带有一堆复选框的页面。每个复选框强制
回发。在用于CheckChanged的事件处理程序功能中,
复选框的事件我需要确定两个值是否相互匹配。如果他们这样做,那么我
想要使用一些javascript来打开一个模态对话框,以允许输入
两个新值。合理?任何帮助都会很棒!谢谢。

- 比尔琼斯
I''m trying to use this.RegisterStartupScript to add some javascript to and
aspx page that will run when the page is loaded. Does anyone know if this
function only works in the Page_Load function? Or can I put it anywhere.
Right now it is inside the eventhandler function that is called on the
"CheckChanged" event of a checkbox, but it never seems to add the javascript code to the page. Is there another way to do this? Let me explain the
problem:

I have a page with a bunch of checkboxes. Each checkbox forces a postback. In the eventhandler function for the "CheckChanged" event of the checkboxes I need to determine if two values match each other. If they do, then I want to use some javascript to open a modal dialog to allow for the input of two new values. Make sense? Any help would be great! Thanks.

- Bill Jones



这篇关于RegisterStartupScript问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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