.net 2.0 credit card validator

E

Eirik Eldorsen

The error I get is controltovalidate is null or not an object.

I'm guessing that the control can't find txtCardNr since it's id becomes
ctl00_cphMainContent_txtCardNr when using masterpages. Am I wrong? Have you
used the control with masterpages?


Eirik
 
E

Eirik Eldorsen

UPDATE:
The error I recieve: document.all.CreditCardValidator1.controltovalidate is
null or not an object

This is probably because the masterpage renames CreditCardValidator1 to
ctl00_cphMainContent_CreditCardValidator1


Eirik
 
E

Eirik Eldorsen

I've created a workaround:
The thing that is'nt working is the clientscript, so I set the variable:
EnableClientScript="False" on the validator.
Now I only get a serverside check, which works perfect. And since I'm using
Ajax the users won't notice the postback to the server :-D
 
G

Guest

You can use something like the following to ensure "unmangling" of control
names:



private string script = "[Label1ID].innerHTML = 'boo!';";
private string scriptKey = "hello";
private bool addScriptTags = true;
protected void Page_Load(object sender, EventArgs e)
{
script = script.Replace("[Label1ID]",Label1.ClientID);
ClientScript.RegisterStartupScript(this.GetType(), scriptKey, script,
addScriptTags);

.. . .

Peter

Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com
 
E

Eirik Eldorsen

Nice trick :)

But to use this, do I have to rewrite the source of the validator? (i'm only
using a ddl file now)


Peter Bromberg said:
You can use something like the following to ensure "unmangling" of control
names:



private string script = "[Label1ID].innerHTML = 'boo!';";
private string scriptKey = "hello";
private bool addScriptTags = true;
protected void Page_Load(object sender, EventArgs e)
{
script = script.Replace("[Label1ID]",Label1.ClientID);
ClientScript.RegisterStartupScript(this.GetType(), scriptKey, script,
addScriptTags);

. . .

Peter

Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com




Eirik Eldorsen said:
UPDATE:
The error I recieve: document.all.CreditCardValidator1.controltovalidate
is
null or not an object

This is probably because the masterpage renames CreditCardValidator1 to
ctl00_cphMainContent_CreditCardValidator1


Eirik
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,292
Messages
2,571,494
Members
48,171
Latest member
EllaHolmwo

Latest Threads

Top