473,386 Members | 1,827 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,386 software developers and data experts.

java script for runat="server" controls

if I type the code as
[HTML]<input type="text" name="txtbox" >[/HTML]
and make the script language as
Expand|Select|Wrap|Line Numbers
  1. function empty()
  2.     {
  3.       if(document.Form1.txtbox.value=="")
  4.          {
  5.     alert("should not be blank");
  6.     return false;
  7.         }
  8.   }
it works well , but If i give the same coding for a runat = "server" it does not work How should I do this ? Is there a possibility for getting the control by getElementById for TextBox as there is no "name" attribute present in ...
Mar 17 '08 #1
3 1680
vee10
141 100+
Hi ,

for the server controls in the page load event u should add the attributes
example txtbox(if it is server control)
txtbox.Attributes.Add("onchange/onclick/whatever is the event","return empty()");


if I type the code as
<input type="text" name="txtbox" >
and make the script language as
function empty()
{
if(document.Form1.txtbox.value=="")
{
alert("should not be blank");
return false;
}
}
it works well , but If i give the same coding for a runat = "server" it does not work How should I do this ? Is there a possibility for getting the control by getElementById for TextBox as there is no "name" attribute present in ...
Mar 17 '08 #2
malav123
217 100+
Hi,
For server controls you can use the script manager.... the form of how to use it is given below,
ScriptManager.RegisterClientScriptBlock(Page, Me.GetType(), "Alert", "alert('Message');", True)
I think this will help u....
Mar 19 '08 #3
if I type the code as
[HTML]<input type="text" name="txtbox" >[/HTML]
and make the script language as
Expand|Select|Wrap|Line Numbers
  1. function empty()
  2.     {
  3.       if(document.Form1.txtbox.value=="")
  4.          {
  5.     alert("should not be blank");
  6.     return false;
  7.         }
  8.   }
it works well , but If i give the same coding for a runat = "server" it does not work How should I do this ? Is there a possibility for getting the control by getElementById for TextBox as there is no "name" attribute present in ...

function tocheck()
{
var variable = document.getElementById("TextBox2").value;
if(isNaN(variable))
{
alert('not a numeric value');
}
}

//IN SIDE CODE BEHIND

Button1.Attributes.Add("onClick", " return tocheck()");

this works well but only after two ckicks why is it ?
thanks in advance
Mar 21 '08 #4

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

Similar topics

3
by: Michael | last post by:
There seem to be two ways to include files on the server: 1. <!-- #include file="header.inc" --> 2. <script language="VBScript" runat="server" src="header.inc"></script> What are the differences...
1
by: Hai Nguyen | last post by:
Hi all I have a several User Controls which require this tag: "<form runat="server">. I tried to have all of these user user controls on the same web page. It kept giving me an error :""A page...
2
by: Hazzard | last post by:
I just realized that the code I inherited is using all asp.net server controls (ie. webform controls) and when I try to update textboxes on the client side, I lose the new value of the textbox when...
5
by: Matt | last post by:
I want to know what is the purpose of runat="server" attribute?? For example, for a submit button, it just submit the form data to the server, whats the differences between <input...
1
by: Matt | last post by:
If the web control has runat="server" attribute, can we say that control is built on the server (on the fly), and not static control?? Please advise.
2
by: Christoph Boget | last post by:
Where in the world can I find information on how to process form input controls that are NOT set to run at the server? The only examples I can find on processing forms use the runat="server" and...
6
by: Martin Eyles | last post by:
Hi, I have a page that contains the following <div runat="server" id="Pikea"> <object runat="server" id="PiTV" style="width:560px; height:560px"...
2
by: Taptu¶ | last post by:
How can I set up runat="server" in dynamic added UserControl ? I have my control created in designer. When I use drag & drop to implement it in website it works. when I use code: Control...
19
by: Scott M. | last post by:
Why do we need runat="server" on our <headtags?
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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
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,...
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.