My first WebService. Parameter passing: Asp to JavaScript?

Last post 05-09-2008 10:11 AM by msnyder0. 1 replies.

Sort Posts:

  • My first WebService. Parameter passing: Asp to JavaScript?

    05-09-2008, 8:13 AM
    • Loading...
    • msnyder0
    • Joined on 06-29-2007, 2:04 PM
    • Manheim, PA
    • Posts 130

    I'm new to this whole WebService thing and I'd like to get some advice before I get too deep in and realize I'm doing it all incorrectly.

    I've been able to get this WebService working by hard coding variable values in for testing purposes, so everything is functional as far as that's concerned. I'm having trouble understanding the logic of passing variables generated by Asp to a JavaScript function.

    I bind the WebService to the GridView which binds variable values to the custom AJAX control InlineEditBox and a HiddenField. I'd like to pass both of these values into the Update("","") function, but I'm not sure how. Any advice? Should I be doing this completely differently? Thanks!

    VB Code
    Protected
    Sub InitInlineBoxes()
      Dim ws As domainName.WebService = New domainName.WebService
      gvList.DataSource = ws.GetComments(tbReportID.Text)
      gvList.DataBind()
    End Sub

    Asp Code
    <
    asp:GridView ID="gvList" runat="server" AutoGenerateColumns="False" BorderWidth="0px" ShowHeader="False">
      <Columns>
        <asp:TemplateField>
          <ItemTemplate>
            <cc2:InlineEditBox
              ID="ieData"
              runat="Server"
              Text='<%# Eval("vcComment") %>'
              CallBackOnBlur="True"
              CallBackFunction="Update(/////What goes here?/////)" />
            <asp:HiddenField ID="hfTaskID" runat="server" Value='<%# Eval("vcTaskID") %>' />
          </ItemTemplate>
          <ItemStyle Width="250px" />
        </asp:TemplateField>
      </Columns>
    </asp:GridView>

    JavaScript Code
    function Update(TaskID, Comment) {
      WebService.UpdateComments(Comment, TaskID);
      return(true);
    }

  • Re: My first WebService. Parameter passing: Asp to JavaScript?

    05-09-2008, 10:11 AM
    • Loading...
    • msnyder0
    • Joined on 06-29-2007, 2:04 PM
    • Manheim, PA
    • Posts 130

    I was able to figure out enough on my own to get this working. I set the CallBackFunction="Update()" in the Asp code and used function Update(result, referrer) in the JavaScript code to get the values. It works fine now, but if anyone can point out better techniques I'd appreciate it. Thanks!

Page 1 of 1 (2 items)