473,387 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Use of Javascript in Asp.net Ajax enabled content pages

Hi

I am new to web programming and I started working with Asp.net 3.5 vwd express edition with ajax tool kit.For about a week now I screened most of articles on use of javascript in asp.net and following is suggested.

1. Use external script file and refer in masterpage and call from content pages by registerclientsciptblock
On Master page it refered as follows"
Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="~/Scripts/TestScript.js">
  2.  
  3. </script> 

2.Place Java script functions in content place holders and refer them by adding attributes to controls. I tried using following function refering it in the clientvalidationfunction
Expand|Select|Wrap|Line Numbers
  1. <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Enter Loan Account Name" ClientValidationFunction="chkloanac" OnServerValidate="Chk" ControlToValidate"TxtLoanSource" ></asp:CustomValidator>
  2.  
  3. <script type="text/jscript">
  4.  
  5. function chkloanac(source, arguments)
  6. {
  7.     var Bal = document.getElementById("<%=TxtBalDebt.ClientID%>");
  8.     var acname = document.getElementById("<%=TxtLoanSource.ClientID%>");
  9. if (Bal.value > 0 && (acname.value == 'NA' || acname.value == ''))
  10.     arguments.IsValid = true;
  11.      else
  12.       arguments.IsValid = false;
  13.  }
  14.  
  15. </script>


3.Build script strings and make call from code behind.example
Expand|Select|Wrap|Line Numbers
  1. Dim sb As New System.Text.StringBuilder() 
  2.  
  3. sb.Append("<script language='javascript'>")
  4. sb.Append("alert('Save Successful');")
  5. sb.Append("</script>")
  6.                                 ScriptManager.RegisterStartupScript(Me, Me.GetType(), "Alert", sb.ToString(), False)
  7.  
All my pages are using ajax controls or extenders and i observe the folllowing.

When I use method 1 and try register the code block, the image placed in a panel for controlling collapsable panel do not load.

Method 2 is not working at all I created a function to refer in custom validation control which would not fire

3.Only mehod 3 is working which again has limitation for using long functions

I request an expert guidence on above subject with known issues and limitations if any.Preferably wih a working example on method-1 or method-2

Thanks in advance
kris
Mar 20 '10 #1
1 1512
Frinavale
9,735 Expert Mod 8TB
Are you using UpdatePanels?
If you are then you have to use the third method to register your script or else it will stop working after a control within the UpdatePanel posts back to the server.

Could you explain what you're trying to accomplish so that I can help you further?

-Frinny
Mar 25 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Bugsy | last post by:
hi fellows pro,,,,, i want some details regarding AJAX. can anyone help me in that .... reply me with some good articles as well as tutorials in (.net)
7
by: julian.tklim | last post by:
Hi, I need to build an editable Datagrid with add & delete buttons on each row using javascript. DataGrid need not be pre-populated with values. To make the thing complicated, one of the...
8
by: Taras_96 | last post by:
Hi everyone, We' ve come to the conclusion that we wish the user to be directed to an error page if javascript is disabled <enter comment about how a webpage shouldn't rely on javascript here :)...
3
by: vunet.us | last post by:
Hello, I am breaking my head running out of ideas about the best solution to my goal. I want to load some pages generated with the server (ASP) and assign their html results to JavaScript, so...
1
by: JohnnieTech | last post by:
I am using some javascript/ajax to load content into a main div. The problem I am running into is that it will work in IE but not in FF. In FF I don't get any sort of load at all. I have a 1...
13
by: mowsen | last post by:
Hello Group, i'm using a little "ajax" loader script to dynamically load files into different "div" tags on my main site. the code for this part looks like: function loader() { var args =...
3
by: Mike TI | last post by:
Oct 20, 2007 01:00pm Hi all When you create an Ajax enabled web site, the application creates the default page with a "Script Manager". I created a Master Page. I then created a "Home"...
22
by: Dan Rumney | last post by:
Hi all, I've been writing Javascript for quite a while now and have, of late, been writing quite a lot of AJAX and AJAX-related code. In the main, my dynamically generated pages are created...
1
by: Mark B | last post by:
This is my first try at using AJAX. I want the calendars to be enabled if the user checks CheckBox1. It works OK for a normal all page refresh but once I introduced the AJAX code it stopped...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.