-
How do I incorporate my previous Javascript code into my new aspx 2.0 pages ?
I am doing research on the simplest possible way to incorporate OnClick events and the related Javascript code from my old web app into my new aspx 2.0 pages ?
I realize I can use code-behind for my web controls, but the only way my events get fired on-the-fly is if I set my web controls to AutoPostBack="true" (not a good option because it causes the entire page to postback when the user clicks on a simple CheckBox).
My requirements are not only for validation purposes, but to also update other parts of my web page as the user is entering values.
For example, take this simple input field validation:
<input type="text" name="txtAmount" Size="15" value="2,000,000" onBlur="txtAmount.value=Math.abs(this.value);if (this.value=='NaN'){this.value=0};">
Very simply, I take the abs value and check for Not a number.
Another example is where I do some calculation then update another part of my web page:
<Input type="checkbox" Name="chkActCur" Value="Checked" onClick="CalcAmount();">
Presently, the CalcAmount() function does some basic multiplication then updates another part of the page.
After the calculations, it updates the fields as follows :
document.OrderEditEntry.txtAmt1.value = cBuyStr;
document.OrderEditEntry.txtAmt2.value = cSelStr;
document.OrderEditEntry.txtAmount.value = cAmt;
I am experimenting with ClientScript.RegisterClientScriptBlock(), but do not have a solid handle on it as of yet.
Any advice would be appreciated.
Thank you,
Bob
-
Phil Weber
http://www.philweber.com
Please post questions to the forums, where others may benefit.
I do not offer free assistance by e-mail. Thank you!
-
I am trying to add some Javascript to my aspx page as follows (within content place holder), however I get an error when my CheckBox control tries to call that function :
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/MasterPage_FxOrder.master" CodeFile="AddModifyOrder.aspx.cs" Inherits="_Default" %>
<asp:Content ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<script language="javascript" type="text/javascript">
function QuoteConv() {
window.alert("in QuoteConv !!");
}
</script>
<asp:FormView ID="FormView1" ... /?
<EditItemTemplate>
<asp:CheckBox ID="chkEditAct_Cur" runat="server" onClick="QuoteConv();" Checked='<% #Eval("act_cur").ToString()=="1" ? false : true %>' OnCheckedChanged="chkEditAct_Cur_CheckedChanged" AutoPostBack="False" /></td>
If I say something like :
onClick="window.alert('Testing')"
then my alert message displays fine. Otherwise it doesn't call the function above.
It's these small things that are driving me nuts at the moment.
Thanks,
Bob
Similar Threads
-
By Phil Weber in forum .NET
Replies: 632
Last Post: 10-01-2003, 12:00 AM
-
Replies: 0
Last Post: 02-01-2001, 02:31 AM
-
Replies: 1
Last Post: 01-19-2001, 06:18 AM
-
By Murray Foxcroft in forum Web
Replies: 5
Last Post: 11-02-2000, 02:42 AM
-
By james chung in forum Web
Replies: 0
Last Post: 09-16-2000, 02:41 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks