-6

Possible Duplicate:
Call c# function in javascript

I have a c# function containing an if statement (if (condition) test=true else test= false )), Can anyone tell me how to call that function in javascript and use the result of that test variable to do an if statement.

The c# file I am referencing is the code behind (.aspx.cs) to an .aspx page. Is there not a way I can call the following function from this .aspx page.

public void write(bool complete)     
{          
System.IO.StreamWriter writer = new System.IO.StreamWriter(Server.MapPath("~file.txt"), true);          
if (complete == true)         
{             
writer.WriteLine("completed");         
}         
else         
{             
writer.WriteLine("FAILED");         
}         
writer.Flush();         
writer.Close();         
writer.Dispose();     
} 
Community
  • 1
  • 1
s j
  • 21
  • 1
  • 3
  • 6
    Refer to your previous question: http://stackoverflow.com/questions/12421716/call-c-sharp-function-in-javascript – Azodious Sep 14 '12 at 10:22

2 Answers2

0

it sounds like in your situation, No, the javascript is running in the browser, and the C# code is running on the server.

You could postback to the server to get it run the C# code if you wanted.

Keith Nicholas
  • 43,549
  • 15
  • 93
  • 156
0

You are repeating the questions. You have got few answers for your previous same question as well Call c# function in javascript

Without postback you cant access the code in .cs file. If you want partial Post back try using AJAX

Community
  • 1
  • 1
Peru
  • 2,871
  • 5
  • 37
  • 66