datagrid linkbutton won't fire Postback randomly

Author Message
bsinclair

  • Total Posts : 2
  • Scores: 0
  • Reward points : 0
  • Joined: 5/23/2005
  • Location:
  • Status: offline
datagrid linkbutton won't fire Postback randomly Monday, May 23, 2005 9:31 AM (permalink)
0
I have a simple linkbutton in a datagrid that works 99.99% of the time. At random times (4 times in the past year) with non-specific data records, a javascript error appears within a simply formatCurrency function and the Postback from the Linkbutton no longer fires. A view source reveals completely valid javascript, matching exactly what is there when the problem does not appear. Does .NET interfer with custom written Javascript, and if so, how can I possibly troubleshoot this?

Here is the code that is having this "random" issue

This is what is in the .ascx file:
<asp:DataGrid id="dgSchwabMFLineItems" Runat="server" Width="100%" ShowHeader="True" GridLines="Horizontal" AutoGenerateColumns="False">
<HeaderStyle CssClass="dgHeaderLeft"></HeaderStyle>
<ItemStyle cssclass="dgCell"></ItemStyle>
<AlternatingItemStyle cssclass="dgAltCell"></AlternatingItemStyle>
<Columns>

<asp:TemplateColumn HeaderText="Lots" HeaderStyle-CssClass="dgHeaderCenter">
<ItemStyle CssClass="lot" HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:LinkButton ID="lbtnMFdgLots" Runat="server" CssClass="lot" CausesValidation="False" CommandName="Lots" text='<%# Container.DataItem("Lots")%>'>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>

<asp:TemplateColumn HeaderText="Created Date" HeaderStyle-CssClass="dgHeaderLeft">
<ItemStyle cssclass="dgCellLeft"></ItemStyle>
<ItemTemplate>
<asp:Label ID="lblMFdgCreateDate" Runat="server" text='<%# FormatDate(Container.DataItem("CreateDate"))%>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I can't imagine this being the issue. Nearly identical (name changes only difference) code executes in a parallel page without ever having an issue.

I'm new to the forum world. Any help is much appreciated.

Thanks

 
#1
    bsinclair

    • Total Posts : 2
    • Scores: 0
    • Reward points : 0
    • Joined: 5/23/2005
    • Location:
    • Status: offline
    Re: datagrid linkbutton won't fire Postback randomly Tuesday, May 24, 2005 2:28 AM (permalink)
    0
    I figured I should probably include the click event handler and the javascript...

    The code for the click event is:

    Private Sub dgSchwabMFLineItems_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgSchwabMFLineItems.ItemCommand
    Try
    If e.CommandName = "Lots" Then
    Dim intLineItemID As Integer
    Dim lbl As Label
    Dim lblN As Label

    lbl = e.Item.FindControl("lblMFdgSymbol")
    lblN = e.Item.FindControl("lblMFdgSymbolName")

    intLineItemID = CInt(dgSchwabMFLineItems.DataKeys(e.Item.ItemIndex).ToString)

    Dim strPage As String = "ReferenceLots.aspx?IID=" & intLineItemID & "&LotType=Ref&SymbolCode=" & lbl.Text & "&WSID=" & clsWS.WorksheetID & "&SName=" & lblN.Text
    Dim strWinParams As String = "'height=300,width=700,left=50,top=50,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,titlebar=yes,toolbar=no'"

    Response.Write(Library.Common.OpenPopUp(strPage, strWinParams))
    End If
    Catch exErr As Exception
    ShowErrorMessage(exErr)
    End Try
    End Sub


    Javascript included with the page:
    <script language="javascript" type="text/javascript">
    function formatCurrency(element)
    {
    var wd
    wd="wholenumber"
    var tempnum
    var x

    // Get the value from the element.
    var tempnum=element.value

    // Remove formatting.
    tempnum = tempnum.replace(",", "")
    tempnum = tempnum.replace(",", "")
    tempnum = tempnum.replace(",", "")
    // validate tempnum
    if ( isNaN(tempnum) )
    {
    alert("Please enter a valid number.");
    element.value = ""
    element.focus()
    return;
    }

    // Check for decimal point in the value
    for (i=0;i<tempnum.length;i++)
    {
    if (tempnum.charAt(i)==".")
    {
    wd="decimal"
    x=tempnum.length-i
    break
    }
    else
    {
    x=0
    }
    }


    // Convert int to string.
    tempnum = tempnum + '';

    // commas
    if (tempnum.length < 3+x)
    {
    // no commas needed.
    element.value = tempnum;
    return
    }
    else
    {
    // Add commas
    for (i=3+x; i<tempnum.length;i=i+4)
    {
    before = tempnum
    after = tempnum
    before = before.substring(0, tempnum.length - i)
    after = after.substring(tempnum.length - i, tempnum.length)
    tempnum = before + "," + after
    }
    }
    element.value = tempnum;
    }
    </script>
     
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9