473,803 Members | 3,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use of Javascript in Asp.net Ajax enabled content pages

6 New Member
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 registerclients ciptblock
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 clientvalidatio nfunction
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 1527
Frinavale
9,735 Recognized Expert Moderator Expert
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
1643
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
3229
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 column need to be a date picker field. I know things will be easier with ASPX datagrid.
8
2856
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 :) >. I've read quite a few posts on how to do this, but none meet my need (the two main suggestions was set a jsEnabled variable in a <scriptsection of the HTML and read it in PHP, and the other suggestion was by default loading the non js page,...
3
1905
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 users could click the links and the content of any selected page would show up immediately, making no requests. So, I have one main page called mainpage.asp which, I think, should get all subpages with content, names are subpage1.asp, subpage2.asp,...
1
1773
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 column 2 row setup in css. The links are in the top div and the content loads in the main div. The only problem I thought may have been causing it was that I had an ID inside of and ID. I changed my links div to a class instead of an ID and that didn't...
13
2539
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 = loader.arguments; switch (args) { case
3
1744
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" page with reference to this master page.
22
2948
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 using Perl on the backend, with Javascript providing limited frontend functionality. As an example, an expanding tree would be fully populated on the server-side and then presented to the browser, with Javascript and CSS being used to vary the...
1
2060
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 working. Any ideas? <%@ Page Language="VB" AutoEventWireup="false" CodeFile="default-ajax.aspx.vb" Inherits="pages_verify_groups_Default" Debug="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
0
9700
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9564
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10310
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10068
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7603
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6841
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3796
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.