我有一个javascript函数"initialize (latitude, longitude)",当我点击我的按钮时,我想从我的文本框传递值来做一些事情。
Protected Sub btnLat_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim latit As TextBox = formView.FindControl("nr_latitudeTextBox")
Dim longit As TextBox = formView.FindControl("nr_longitudeTextBox")
Page.ClientScript.RegisterStartupScript(Me.GetType(), "initialize", "initialize(" & latit.Text, longit.Text & ");", True)
End Sub
但是当我尝试这样做时,我得到了错误
重载解析失败,因为没有可访问的"RegisterStartupScript"接受此数量的参数。
您刚刚实现了错误的代码。改为。
如果你的initialize
函数需要字符串变量,那么使用代码;
Page.ClientScript.RegisterStartupScript(Me.GetType(),
"initialize", "initialize('" & latit.Text & "','" & longit.Text & "');", True)
如果initialize
期望整数,则;
Page.ClientScript.RegisterStartupScript(Me.GetType(),
"initialize", "initialize(" & latit.Text & "," & longit.Text & ");", True)