在 ASP.NET 中向用户显示警告消息
我有一个在运行时创建的弹出窗口,并且可以有多个文本区域。我需要计算其文本区域的字符数,并在用户超过最大数量时向用户显示警告。 由 ASP.NET 编写的应用程序。我无法使用“onClientClick”,因为我不知道文本区域的名称,他们创建了运行时,我将他们的名称保存在服务器端的字典中。 我尝试使用“RegisterStartupScript”来调用java脚本“alert”方法,但它不起作用。事实上它可以工作,但它会执行所有保存代码并在之后显示警报。但我想在用户确认后执行保存代码。 我想用 jquery 打开消息框,但我当前的窗口是用 AJAX 打开的,打开另一个 AJAX 页面不太好。 您能帮助我并告诉我如何显示警告或解决我的问题吗?
I have a pop up window that is create in run time, and can have several text area. I need to count number of characters of its text area and show warning to users if they pass maximum number.
the application wrote by ASP.NET. I can't use "onClientClick", because I don't know the name of the text area, they created run time and I save their name in a dictionary that just have in server side.
I tried to use "RegisterStartupScript" to call java script "alert" method but it doesn't work. In fact it works but it execute all the save code and show alert after that. but I want to execute save code after user confirmation.
I think to open message box with jquery but my current windows is opening with AJAX and it won't nice to open another AJAX page.
Can You help me and show me the way to show warning, or solving my problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在文本区域中使用 onkeypress 或 onkeyup 事件,并使用如下函数来显示警告:
以及 JavaScript 函数:
You need to use the onkeypress or onkeyup events in the text area, and use a function like this to show the warning:
And the JavaScript function: