Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


datagrid linkbutton won't fire Postback randomly

 
Logged in as: Guest
arrSession:exec spGetSession 2,4,3087
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP.NET >> datagrid linkbutton won't fire Postback randomly
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 datagrid linkbutton won't fire Postback randomly - 5/23/2005 8:31:43 AM   
  bsinclair

 

Posts: 2
Score: 0
Joined: 5/23/2005
From:
Status: offline
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
 
 
Post #: 1
 
 Re: datagrid linkbutton won't fire Postback randomly - 5/24/2005 1:28:38 AM   
  bsinclair

 

Posts: 2
Score: 0
Joined: 5/23/2005
From:
Status: offline
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>

(in reply to bsinclair)
 
 
Post #: 2
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP.NET >> datagrid linkbutton won't fire Postback randomly Page: [1]
Jump to:





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
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts