admin管理员组

文章数量:1389750

I have a javascript function "initialize (latitude, longitude)" and when I click on my button I want to pass the value from my textbox to do something.

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

But when I try to do this I get the error

Overload resolution failed because no accessible "RegisterStartupScript" accepts this number of arguments.

I have a javascript function "initialize (latitude, longitude)" and when I click on my button I want to pass the value from my textbox to do something.

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

But when I try to do this I get the error

Overload resolution failed because no accessible "RegisterStartupScript" accepts this number of arguments.

Share Improve this question edited Jun 5, 2019 at 18:09 TylerH 21.1k79 gold badges79 silver badges114 bronze badges asked May 14, 2013 at 12:50 migmigmigmig 1413 gold badges6 silver badges16 bronze badges 1
  • check this sample codeproject./Articles/11098/… – Akshay Joy Commented May 14, 2013 at 12:55
Add a ment  | 

1 Answer 1

Reset to default 3

You have just implemented the code wrongly. Change it to.

If your initialize function expects string variables then use the code;

Page.ClientScript.RegisterStartupScript(Me.GetType(), 
"initialize", "initialize('" & latit.Text & "','" & longit.Text & "');", True)

If initialize expects integers then;

Page.ClientScript.RegisterStartupScript(Me.GetType(), 
"initialize", "initialize(" & latit.Text & "," & longit.Text & ");", True)

本文标签: javascriptHow to pass 2 parameters through RegisterStartupScriptStack Overflow