I'ts hard to tell what exactly you're adding to the "onclick" attribute of
the submit button, but I would guess that it is adding a client-side script
call for validation to it.
The string you are adding is
"return checkForm{'" + this + "','" + SomeTextBox.Text + "')"
The reference to "this" (without quotes) is a reference to the Page class
itself. Apparently, you're not working in Visual Studio.Net, because it
would give you a compile-time exception, as a Page class is not a string.
As I don't know what it is you want to concatenate into the string by
referencing "this," I can only guess, and I hate to guess.
But, if I were to guess, I would suppose that you really want to put the
string literal "this" (which is often used in JavaScript function calls to
pass a reference to the element that called the function) in your code. If
so, there is no concatenation required:
"return checkForm{'this','" + SomeTextBox.Text + "')"
Of course, this is *still* wrong, as it is not passing a reference to the
element, but the literal string "this" to the function. To pass a reference
to the element, you would need to remove the single quotes:
"return checkForm{this,'" + SomeTextBox.Text + "')"
Of course, this is probably not what you need either. For most client-side
form validation, a reference to the *form* is passed. Passing a reference to
a submit button would be generally pointless.
So, again, presuming that you *do* want to pass a reference to the form
itself to the function, this would have to be modified as follows:
"return checkForm{this.form,'" + SomeTextBox.Text + "')"
ASP.Net is all about HTML, JavaScript, CSS, and client-side technologies.
So, you have 2 skillsets to master:
1.Client-side document technologies (as mentioned above)
2. Server-side .Net programming technology
It is important that you understand both fully, or you will constantly be
plagued with this sort of issue. The Microsoft MSDN Library online is full
of information about both .Net and Internet programming technologies in
general (including HTML, DHTML, JavaScript, CSS, XML, etc). You can find it
at:
http://msdn.microsoft.com
I spend an hour or 2 a day studying this reference on average. And I've been
a developer for about a dozen years.
The nice thing is, you don't have to know it all to do it all. You just have
to know where to find a definitive answer. And if you bookmark the MSDN
Library, you will be well on your way.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
There's a seeker born every minute.
- Dr. "Happy" Harry Cox
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OB**************@TK2MSFTNGP12.phx.gbl...
"this," in the context of your code, is a reference to the page class.
--
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Complex things are made up of
Lots of simple things.
<de*****@hotmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...I have a piece of c# code in the Page_Load function.
submitButton.Attributes.Add("onClick", "return checkForm('" + this +
"','" + SomeTextBox.Text + "')");
When I click the submitButton, it calls the javascript function, but
the value is not being passed....
I cannot find a work around.
Thanks in advance