Calling a Page Method In Javascript

Posted by Vuyiswamb under C# on 8/10/2010 | Views : 15540 | Status : [Member] [MVP] [Administrator] | Replies : 1
Good Day All

I have a Method that i have defined that i will access in JavaScript(Page Method) and its defined like this

    [WebMethod, System.Web.Script.Services.ScriptMethod]
public static void Getadata(String StrSearch)
View obj = new View();

// return Scriptt;

And the Bind_SearchBox() method is a non static method that is defined in this code behind of this page and View is the class name of the Page.

and the Toggle function

function ToggleCollapsePane() {

var splitter = $find("RadSplitter1");

var pane = splitter.getPaneById("LeftPane");

if (!pane) return;

if (pane.get_collapsed()) {
else {


so the Getadata() Function will call the Bind_SearchBox() Function and pass the Parameter and the function Bind_SearchBox() will do the Job as you can see at the end it sets some control to visible. But this does not bring me back results(The RadScheduler1 is not binded with data and RadPanelBar1 does not show anything)

I had a search button that is that was calling the same method and passing the same parameters but it could show results and it looked like this

    protected void btnSearch_Click(object sender, EventArgs e)

RadToolBarItem textItem = RadToolBar1.FindItemByText("Button1");

TextBox txtseach = (TextBox)textItem.FindControl("txtsearch");

if (txtseach.Text != "")



Microsoft JScript runtime error: Sys.Net.WebServiceFailedException: The server method 'Getadata' failed with the following error: System.NullReferenceException-- Object reference not set to an instance of an object.

If i click this above button it will show results. The txtseach have the same text and it calls the same method but when i call this function and inject parameters from page method it does not work.

I am Surprised.


Thank you for posting at Dotnetfunda


Posted by: Poster on: 8/10/2010 [Member] Starter

Login to post response