ScriptManager的。 RegisterClientScript块不会采用动态值 [英] Scriptmanager. RegisterClientScript block doens't take dynamic values

查看:60
本文介绍了ScriptManager的。 RegisterClientScript块不会采用动态值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Experts,



我正在使用网络服务。 webservice的结果将以数组格式显示,Web服务的文档ID,消息和状态。单击该按钮后,将使用Web服务并通过它发送必要的数据。现在我想在使用Web服务并在下面发送数据后在我的Web应用程序中显示一条消息



  Dim  ms 作为 字符串 =   alert('成功提交,DocId为' +结果( 0  ).docId.ToString()+  ') 
ScriptManager.RegisterClientScriptBlock( TryCast (发件人,控制), GetType (), alert,ms, True





在上面的代码结果中(0).docId.ToString()的文档编号如

 S01000134487194290 





我f我给我的ms字符串没有结果(0).docId.tostring()我可以看到流行消息说成功提交下面的代码



  Dim  ms 作为 字符串 =   alert('成功提交,DocId为') 
ScriptManager.RegisterClientScriptBlock(< span class =code-keyword> TryCast (发件人,控制), GetType (), alert,ms, True





但是如果我想显示文档ID,我看不到弹出消息。没有错误,但我不明白有什么不对。任何人都可以帮我找出错误吗?或者让我明白什么是错的?

解决方案

你在破解JavaScript中的字符串。



所以,这就是JS实际看到的:

 alert(' 已成功提交且DocId为' S01000134487194290 '  





这是无效的JS。



将你的VB更改为:

  Dim  ms 作为 字符串 =   alert('成功提交,DocId为 +结果(< span class =code-digit> 0 )。docId.ToString()+  ')  





那样你最终会得到:

 alert(' 已成功提交且DocId为S01000134487194290'); 


Hello Experts,

I am consuming a webservice. Result of the webservice will be in an array format showing, the document Id, Message and Status of the web service. After clicking on the button, web service will be consumed and necessary data is sent through it. Now I want to show a message in my web application after web service is consumed and data is sent as below

Dim ms As String = "alert('Successfully Submitted and DocId is'" + result(0).docId.ToString() + "' )"
                    ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "alert", ms, True)



In the above code result(0).docId.ToString() has a document number like "

S01000134487194290



If I give my ms string without the result(0).docId.tostring() I can see the pop message saying successfully submitted with below code

Dim ms As String = "alert('Successfully Submitted and DocId is ')"
                   ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "alert", ms, True)



But If I want to show the document ID , I don't see a pop up message. There is no error but I don't understand what is wrong. Can anyone help me in finding out the error? or in making me understand what is wrong?

解决方案

You're breaking the string in JavaScript.

So, this is what JS is actually seeing:

alert('Successfully Submitted and DocId is'S01000134487194290')



That is invalid JS.

Change your VB to be:

Dim ms As String = "alert('Successfully Submitted and DocId is " + result(0).docId.ToString() + "' )"



That way you'll end up with:

alert('Successfully Submitted and DocId is S01000134487194290');


这篇关于ScriptManager的。 RegisterClientScript块不会采用动态值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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