473,396 Members | 2,024 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,396 software developers and data experts.

vaidation and non-server controls

Is there a simple way to get a RequiredFieldValidator to work with a
non-server control?

I have a hidden field that I cannot make into a server control because I
have to change it's value with client side javascript. But I do want to
make sure I validate there is a value before the form is submitted.

I can write a client side function myself for this, but since I'm using an
<asp:LinkButton /> for the submit action, I'm not sure how I'd interfere
with the submit process.
Nov 19 '05 #1
2 962
"Random" <ci*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Is there a simple way to get a RequiredFieldValidator to work with a
non-server control? Nope!
I have a hidden field that I cannot make into a server control because I
have to change it's value with client side javascript. But I do want to
make sure I validate there is a value before the form is submitted. ???

YOU CAN!!!

<%
MyHiddenField.Attributes("style") = "display:none;";
%>
<asp:Textbox ID="MyHiddenField" Runat="server" />
<script language="javascript">
document.-getElementById('<%=MyHiddenField.ClientID%>').valu e = 'xxx';
</script>

Where ist the problem?
I can write a client side function myself for this, but since I'm using an
<asp:LinkButton /> for the submit action, I'm not sure how I'd interfere
with the submit process.


--
Daniel Fisher(lennybacon)
MCP ASP.NET C#
Blog: http://www.lennybacon.com/

Nov 19 '05 #2
Hmm, I thought I'd tried the inline assignment of the ClientID to the
javascript function and had a problem with it. I'll have to give that
another shot.

Anyway, I did, in the meantime, manage to attach to the submit event and get
the functionality I wanted...

<script language="javascript">
window.onload = checkSel;

function checkSel() {
<<do a check to see if I'm on the right view>>
if (<<we are on the right view>>) {
document.forms[0].onsubmit = valPType;
}
}

function valPType() {
if (document.getElementById('hdnID').value != 0) {
return true;
}
else {
alert('Please indicate the type of partnership in which you wish
to participate.');
return false;
}
}
</script>

"Daniel Fisher(lennybacon)" <info@(removethis)lennybacon.com> wrote in
message news:Oj**************@TK2MSFTNGP15.phx.gbl...
"Random" <ci*******@hotmail.com> wrote in message
news:%2***************@TK2MSFTNGP09.phx.gbl...
Is there a simple way to get a RequiredFieldValidator to work with a
non-server control?

Nope!
I have a hidden field that I cannot make into a server control because I
have to change it's value with client side javascript. But I do want to
make sure I validate there is a value before the form is submitted.

???

YOU CAN!!!

<%
MyHiddenField.Attributes("style") = "display:none;";
%>
<asp:Textbox ID="MyHiddenField" Runat="server" />
<script language="javascript">
document.-getElementById('<%=MyHiddenField.ClientID%>').valu e = 'xxx';
</script>

Where ist the problem?
I can write a client side function myself for this, but since I'm using
an <asp:LinkButton /> for the submit action, I'm not sure how I'd
interfere with the submit process.


--
Daniel Fisher(lennybacon)
MCP ASP.NET C#
Blog: http://www.lennybacon.com/

Nov 19 '05 #3

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

Similar topics

4
by: Simon | last post by:
Hi there. I have a form on which I have a date of expiry which is built from 3 select fields to build the day, month and year, this all works OK and the data is being built and added to the...
5
by: klaus triendl | last post by:
hi, recently i discovered a memory leak in our code; after some investigation i could reduce it to the following problem: return objects of functions are handled as temporary objects, hence...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
25
by: Yves Glodt | last post by:
Hello, if I do this: for row in sqlsth: ________pkcolumns.append(row.strip()) ________etc without a prior:
32
by: Adrian Herscu | last post by:
Hi all, In which circumstances it is appropriate to declare methods as non-virtual? Thanx, Adrian.
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
14
by: Patrick Kowalzick | last post by:
Dear all, I have an existing piece of code with a struct with some PODs. struct A { int x; int y; };
11
by: ypjofficial | last post by:
Hello All, So far I have been reading that in case of a polymorphic class ( having at least one virtual function in it), the virtual function call get resolved at run time and during that the...
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
399
by: =?UTF-8?B?Ik1hcnRpbiB2LiBMw7Z3aXMi?= | last post by:
PEP 1 specifies that PEP authors need to collect feedback from the community. As the author of PEP 3131, I'd like to encourage comments to the PEP included below, either here (comp.lang.python), or...
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: 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...
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
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,...
0
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...
0
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...
0
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,...
0
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...

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.