1
  function calcRoute() {
        var start = document.getElementById('start').value;
        var end = document.getElementById('end').value;


        var request = {
            origin: start,
            destination: end,

            travelMode: google.maps.TravelMode.DRIVING
        };
        directionsService.route(request, function(response, status) {
            if (status == google.maps.DirectionsStatus.OK) {
                directionsDisplay.setDirections(response);
                var route = response.routes[0];
                var summaryPanel = document.getElementById('directions_panel');
                summaryPanel.innerHTML = '';
                // For each route, display summary information.
                for (var i = 0; i < route.legs.length; i++) {
                    var routeSegment = i + 1;
                    summaryPanel.innerHTML += '<b>Route Segment: ' + routeSegment + '</b><br>';
                    summaryPanel.innerHTML += route.legs[i].start_address + ' to ';
                    summaryPanel.innerHTML += route.legs[i].end_address + '<br>';
                    summaryPanel.innerHTML += route.legs[i].distance.text + '<br><br>';
                }
            }
        });
    }

    google.maps.event.addDomListener(window, 'load', initialize);

ボタン イベントが発生しません...サーバー側コントロールを使用して 2 つのドロップダウン リスト コントロールを使用してルート案内を表示したいのですが、ボタン イベントが発生しません...どうすればよいですか?

 <asp:Button ID="btnsubmit" runat="server" OnClientClick="return calcRoute();" Text="Submit" />

javascriptメソッドをサーバーサイドに呼び出す方法...教えてください..

4

3 に答える 3

0
Syntax : 
public void RegisterClientScriptBlock(
    Type type,
    string key,
    string script,
    bool addScriptTags
)

Parameters

type
    Type: System.Type

    The type of the client script to register. 

key
    Type: System.String

    The key of the client script to register. 

script
    Type: System.String

    The client script literal to register. 

addScriptTags
    Type: System.Boolean

    A Boolean value indicating whether to add script tags.

  public void Page_Load(Object sender, EventArgs e)
  {
    // Define the name and type of the client scripts on the page.
    String csname1 = "PopupScript";
    String csname2 = "ButtonClickScript";
    Type cstype = this.GetType();

    // Get a ClientScriptManager reference from the Page class.
    ClientScriptManager cs = Page.ClientScript;

    // Check to see if the startup script is already registered.
    if (!cs.IsStartupScriptRegistered(cstype, csname1))
    {
      String cstext1 = "alert('Hello World');";
      cs.RegisterStartupScript(cstype, csname1, cstext1, true);
    }

    // Check to see if the client script is already registered.
    if (!cs.IsClientScriptBlockRegistered(cstype, csname2))
    {
      StringBuilder cstext2 = new StringBuilder();
      cstext2.Append("<script type=\"text/javascript\"> function DoClick() {");
      cstext2.Append("Form1.Message.value='Text from client script.'} </");
      cstext2.Append("script>");
      cs.RegisterClientScriptBlock(cstype, csname2, cstext2.ToString(), false);
    }
  }
于 2013-10-01T06:02:23.190 に答える
0

私は "return" false 条件を追加していません...私のボタンは現在 PostBack を取得しています。これは問題になる可能性があります。だから追加

false を返します。

調子..

その後、正常に動作します...応答をありがとう..

于 2013-10-01T09:19:31.997 に答える