MOSS Forum

Ask Question   UnAnswered
Home » Forum » MOSS       RSS Feeds

Calling C# Method from Javascript in the User Control of Visual Web

  Asked By: Joseph    Date: Jan 22    Category: MOSS    Views: 5633

I need a help. I googled a lot, but didn't find a good solution.
May be I am missing something. Kindly help me.

I have a textbox in a User Control (ascx) of a Visual web part. When the
user enters a text and focus is lost from the textbox, I need to call a
method from a class (in a separate dll) through a javascript function in
ascx markup. Can anyone point me in the right direction? I tried using
PageMethods object, but unfortunately, this object doesn't work inside ascx,
hence I tried putting this in a CEWP in the page which hosts this web part,
but no luck. I also tried using SP.js (Client Object model) in 2010, but
didn't get any success. It may be also due to the fact that, I may be wrong,
as I didn't get any proper guidance. Can anyone help me at the earliest?



2 Answers Found

Answer #1    Answered By: Joey Soto     Answered On: Jan 22
Answer #2    Answered By: Gerard Randall     Answered On: Jan 22

JS runs in the front end...C# runs in the back-end...that's why the general
answer is no..

But this is what Ajax can be used for...specifically, Ajax (which is JS) can
call a web service method (in the back-end) that can be written in C#...

This is not trivial to setup/debug,etc. but it is architecturally possible...