473,789 Members | 3,013 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript in content pages

Hi,

I have a master page and content page. In content page I have to
validate the text boxes for
name,address, phone number and email address etc. But as content pages
doersn't have html section not head or body section so, where I use
this java script in content page to validate the form.

Thanks

May 2 '07 #1
3 14782
<bb****@yahoo.c omwrote in message
news:11******** **************@ n76g2000hsh.goo glegroups.com.. .
I have a master page and content page. In content page I have to
validate the text boxes for
name,address, phone number and email address etc. But as content pages
doersn't have html section not head or body section so, where I use
this java script in content page to validate the form.
Anywhere you like - I usually put it at the very beginning of the content
page...

--
http://www.markrae.net

May 2 '07 #2
Use the RegisterClientS criptBock method. Example:
--codebehind for somepage.cs, which uses a masterpage (although this doesn't
matter)

Page.aspx:
<input type="button" onclick="someth ing();" value="click me" />

Page.aspx.cs:
protected void Page_Load(objec t sender, EventArgs e)
{
Page.RegisterCl ientScriptBlock ("uniqueString" , "<script
type=\"text/javascript\">fu nction something(){
alert('somethin g'); }</script>");
}
Doing the Javascript construction in the .cs file can get annoying and
messy, so I will often put the javascript in the aspx (or ascx) file in a
literal control that I never display, but read the contents of, like so:

Page2.aspx:
<input type="button" onclick="somefu nction();" value="clickme" />
<asp:Literal ID="litClientSc ript" runat="server" Visible="false" >
<script type="text/javascript">
function somefunction() {
var x = 3;
var y = 9;
alert(x*y);
}
</script>
</asp:Literal>
Page2.aspx.cs:
protected void Page_Load(objec t sender, EventArgs e)
{
Page.RegisterCl ientScriptBlock ("clientScript" , litClientScript .Text);
}

Ray at work


<bb****@yahoo.c omwrote in message
news:11******** **************@ n76g2000hsh.goo glegroups.com.. .
Hi,

I have a master page and content page. In content page I have to
validate the text boxes for
name,address, phone number and email address etc. But as content pages
doersn't have html section not head or body section so, where I use
this java script in content page to validate the form.

Thanks
May 2 '07 #3
Mark is correct that this will work. You can put javascript anywhere you
like. Purists would advise against it, but in reality, it'll still work
just the same. The one problem you can run into is the way that javascript
is loaded and executed at the same time, so if you call something that
appears higher up in the page, you'll get an error in the browser. Example:

<body>
<script type="text/javascript">
somefunc('first call'); //this will fail here
</script>

<script type="text/javascript">
function somefunc(s) {
alert(s);
}
</script>

<script type="text/javascript">
somefunc('secon d call'); //this will work
</script>
</body>

Ray at work
"Mark Rae" <ma**@markNOSPA Mrae.netwrote in message
news:u2******** ******@TK2MSFTN GP05.phx.gbl...
<bb****@yahoo.c omwrote in message
news:11******** **************@ n76g2000hsh.goo glegroups.com.. .
>I have a master page and content page. In content page I have to
validate the text boxes for
name,address , phone number and email address etc. But as content pages
doersn't have html section not head or body section so, where I use
this java script in content page to validate the form.

Anywhere you like - I usually put it at the very beginning of the content
page...

--
http://www.markrae.net
May 2 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
4554
by: dezza | last post by:
Hi, I am developing a web application that is a series of pages, rather like a wizard. Because all of the pages basically have the same navigation, and require the navigation buttons in the same part of every screen, I have put the navigation buttons on the Master Page. The Content Pages, when they load, are able to change the caption of the navigation buttons as required by accessing the properties of the Master Page.
3
1312
by: Chris Lincoln | last post by:
I am currently working on a company site and have run into a problem with the search aspect of the site. I am running .net 2.0 and iis 5.1. The issue is as follows: Indexing Service is properly searching the pages within the search scope, however, content pages that I have set up to use various masterpages are not being displayed properly (no doctitle). From what I've researched, this is because indexing service searches for content...
3
6360
by: vikramp | last post by:
Hi, I am still new to ASP.NET 2.0 and trying to develope something using Master pages. My problem is: I have a master page that contains Logo image and a navigation menu at the top of the page so that this will be displayed on all the content pages automatically. This works fine for the content pages that are stored in the same
0
895
by: bobby421 | last post by:
Hi, I have a master page and content page. In content page I have to validate the text boxes for name,address, phone number and email address etc. But as content pages doersn't have html section not head or body section so, where I use this java script in content page to validate the form. Thanks
2
1714
by: Stratum | last post by:
It's an old question, and I apologize for raising it again. I use ImageButton objects on my ASP.Net master page to navigate to content pages. For each button, I have two images. One image shows black print on a white background, and the other image shows the same printing in white on a red background to indicate the content page which is presently loaded. When I navigate between pages, I want the
0
947
by: kewldudehere | last post by:
Hi folks, I have a content Page and have the following Code in the content tag. <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server"> <input type="Text" name="timestamp" value=""/> <a href="javascript:show_calendar('document.form1.ContentPlaceHolder1.timestamp',document.form1.ContentPlaceHolder1.timestamp.value);"><img src="cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the...
1
1526
by: krisviswa | last post by:
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" <script type="text/javascript" src="~/Scripts/TestScript.js"> </script>
0
10408
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10199
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...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9983
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...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6768
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
5417
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...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.