Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

How to assign javascript to C# ?

  Asked By: Pauline    Date: Dec 27    Category: Sharepoint    Views: 2776

Is there a way to store javascript variable to C# string variable.
I'm trying to achive this in my asp.net <http://asp.net> web application.

private void Page_Load(object sender, System.EventArgs e)


string userName ="Hello : ";

Response.Write("<script> language='javascript'>function AlertBox(){ var


Response.Write("<input value='Find User' type=button onclick=\"
AlertBox();\" >");

//need be append userName with var name='Tom'...something like

Label1.Text = userName;//output should be Hello : Tom


I know this is not a SharePoint yahoo group question. but later i'm
implementing this functionaytllity in a web part application.



3 Answers Found

Answer #1    Answered By: Jonathan Justice     Answered On: Dec 27

by using getElementbyID function get the server side control in javascript  and
assign there the value.

Answer #2    Answered By: Dhanishta Bapakar     Answered On: Dec 27

Try using HtmpInputHidden control. This control can be accessed from both C# as
well as Javascript.

Answer #3    Answered By: Easy Tutor     Answered On: Dec 27

Hello, this is a good article:


Didn't find what you were looking for? Find more on How to assign javascript to C# ? Or get search suggestion and latest updates.