How do I incorporate my previous Javascript code into my new aspx 2.0 pages ?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: How do I incorporate my previous Javascript code into my new aspx 2.0 pages ?

  1. #1
    Join Date
    Dec 2005
    Posts
    17

    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

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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!

  3. #3
    Join Date
    Dec 2005
    Posts
    17
    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

  1. Microsoft's C++ bigotry
    By Phil Weber in forum .NET
    Replies: 632
    Last Post: 10-01-2003, 12:00 AM
  2. Javascript Code
    By Paul in forum Web
    Replies: 0
    Last Post: 02-01-2001, 02:31 AM
  3. help with code (javascript)
    By john in forum Web
    Replies: 1
    Last Post: 01-19-2001, 06:18 AM
  4. Sample Sites.
    By Murray Foxcroft in forum Web
    Replies: 5
    Last Post: 11-02-2000, 02:42 AM
  5. 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center