1

This is used in .cs page of asp.net. Please explain the meaning of the following code:

Page.ClientScript.RegisterStartupScript(this.GetType(), "'" + scriptKey + "'", ValidationScript.ToString(), false);

4 Answers 4

2

This registers some javascript on the client - ValidationScript whatever that is.

This means that ValidationScript will appear in the output so to the client so that it may be executed by it. I'm guessing to carry out validation routines.

Sign up to request clarification or add additional context in comments.

Comments

2

It registers a javascript block that will execute when the page has finished loading. The first two arguments are used to idenfity the script (only one startup script with the given type and key can be registered in the page.

Check the documentation for more details.

Comments

1

Please read this - http://msdn.microsoft.com/en-us/library/aa479390.aspx

3 Comments

I don't recall ever saying that. In fact, that looks remarkably like a quote from the marketing materials for Jon Skeet's book "C# in Depth". manning.com/skeet -- I did not write those marketing materials, I just wrote the foreword.
@Eric: That's pretty funny if you were to write marketing hype like that :)
Ohh .. my bad. It is indeed from C# in Depth's back cover. I read it sometime back and remembered it like that. Should have checked before quoting. So editing the answer.
0

For a detailed explanation, just check msdn: msdn.

But basically all that happens is, the javascript gets registered on the page, and the type/key combination is used, to make sure, there won't be any duplications.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.