0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

C#のメッセージ定数をJavascriptへ渡して使用する

Posted at

string msg = "初めまして 記録用の投稿です"

「'" + 変数名 + "'」で変数msgを囲んであげることでJavascript側に渡して使用可能になる。
string script = "MESSAGE('" + msg + "');";

ScriptManager.RegisterStartupScript(this, this.GetType(), "MessageScript", script, true);

ここまでがC#側

Javascriptではfunction MESSAGE(aMsg) {}で呼び出してあげればmsgの値を使用可能になる。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?