这段代码怎么了? [英] Whats wrong this code ?

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

问题描述

code (aspx) :    
function OpenPopup_CariMember(jManfaat) 
{
  var Return;
  Return = window.showModalDialog("../Search/SearchMember.aspx?  page=CWD&jManfaat=" + jManfaat, "","dialogWidth:1100px;dialogHeight:620px;status:no;scroll:no;")
}
     
code behind (aspx.vb) :

 Protected Sub Drop_jnsMnft_BeneF_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Drop_jnsMnft_BeneF.SelectedIndexChanged
        Me.btn_srcM_BeneF.Attributes.Add("onclick", "javascript:return OpenPopup_CariMember(" + Drop_jnsMnft_BeneF.SelectedItem.Text + ")")
    End Sub





我尝试了什么:



i不知道这段代码有什么问题。

假设Drop_jnsMnft_BeneF.SelectedItem的值.Text =欺诈

和我跑的时候,这样的错误JavaScript运行时错误:'欺诈'未定义



请帮帮我



What I have tried:

i dont know what wrong this code.
assumption the value of Drop_jnsMnft_BeneF.SelectedItem.Text = "fraud"
and when i run,, error like this "JavaScript runtime error: 'Fraud' is undefined"

please help me

推荐答案

如果你想将文字文本传递给一个函数,你需要将它包装在引号中。你的代码在客户端生成这个js



If you want to pass literal text to a function you need to wrap it in quotes. Your code is generating this js on the client

OpenPopup_CariMember(Fraud)





所以它将欺诈视为一个变量。你需要这个





So it is treating Fraud as a variable. You need this instead

OpenPopup_CariMember('Fraud')





因此,欺诈被视为文本。





So Fraud is treated as text.

Me.btn_srcM_BeneF.Attributes.Add("onclick", "javascript:return OpenPopup_CariMember('" + Drop_jnsMnft_BeneF.SelectedItem.Text + "')")


这篇关于这段代码怎么了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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