Click here to Skip to main content
15,911,891 members
Home / Discussions / C#
   

C#

 
AnswerRe: Owned Forms issue Pin
Luc Pattyn10-Aug-10 3:54
sitebuilderLuc Pattyn10-Aug-10 3:54 
GeneralRe: Owned Forms issue Pin
spankyleo12310-Aug-10 4:32
spankyleo12310-Aug-10 4:32 
AnswerRe: Owned Forms issue Pin
Luc Pattyn10-Aug-10 4:46
sitebuilderLuc Pattyn10-Aug-10 4:46 
GeneralRe: Owned Forms issue Pin
spankyleo12310-Aug-10 4:57
spankyleo12310-Aug-10 4:57 
GeneralRe: Owned Forms issue Pin
Luc Pattyn10-Aug-10 5:06
sitebuilderLuc Pattyn10-Aug-10 5:06 
GeneralRe: Owned Forms issue Pin
spankyleo12310-Aug-10 5:20
spankyleo12310-Aug-10 5:20 
GeneralRe: Owned Forms issue Pin
DaveyM6910-Aug-10 5:20
professionalDaveyM6910-Aug-10 5:20 
QuestionCalling a Page Method In Javascript [modified] Pin
Vimalsoft(Pty) Ltd9-Aug-10 23:22
professionalVimalsoft(Pty) Ltd9-Aug-10 23:22 
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();
    obj.Bind_SearchBox(StrSearch);

   // 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. Now i debugged this and i see the results are passed to the method and the Method is Defined like this

public void Bind_SearchBox(String Search)
    {


        ViewerService.ViewerService obj = new ViewerService.ViewerService();

        String SessionKey = obj.newSession();

        DateTime Date1 = Convert.ToDateTime("1980-01-01");
        DateTime Date2 = Convert.ToDateTime("2012-12-31");

        ViewerService.extract extract = obj.getObjects(SessionKey, Search, Date1, false, Date2, false, "", "");
        try
        {
            RadPanelBar1.Items.Clear();
            RadScheduler1.Appointments.Clear();

            int Len = extract.set.Length;
            for (int i = 0; i < Len; i++)
            {
                ViewerService.vertex value = extract.set[i];

                String PanelClass = value.meta;
                PanelClass = PanelClass.Replace(Remstr, "");
                PanelClass = PanelClass.Replace(Remstr2, "");
                Appointment app = null;
                if (value.atom != null)
                {

                    RadPanelItem pane = RadPanelBar1.Items.FindItemByText(PanelClass);
                    if (pane == null)
                    {
                        RadPanelItem nwpane = new Telerik.Web.UI.RadPanelItem(PanelClass);
                        RadPanelItem nwpaneSpliter = new Telerik.Web.UI.RadPanelItem(PanelClass);
                        nwpaneSpliter.IsSeparator = true;
                        RadPanelBar1.Items.Add(nwpane);
                        pane = nwpane;
                    }
                    if (value.meta == "za.co.abacus.C_EVENT")
                    {
                        app = new Appointment();
                    }

                    int atomLen = value.atom.Length;
                    for (int j = 0; j < atomLen; j++)
                    {
                        ViewerService.atom atm = value.atom[j];

                        if (atm.meta.Contains("za.co.reactor.A_LABEL"))
                        {
                            RadPanelItem NewItem = new RadPanelItem(atm.content);
                            pane.Items.Add(NewItem);
                            if (app != null)
                            {
                                app.Subject = atm.content;
                                app.Description = atm.content;
                                app.ID = value.key;
                            }

                        }

                        if (app != null && atm.meta.Contains("za.co.abacus.C_EVENT"))
                        {
                            app.ID = atm.content;
                        }
                        if (app != null && atm.meta.Contains("za.co.reactor.A_HORIZON"))
                        {
                            app.Start = Convert.ToDateTime(atm.content);
                        }
                        if (app != null && atm.meta.Contains("za.co.reactor.AA_HORIZON"))
                        {
                            app.End = Convert.ToDateTime(atm.content);
                        }
                        if (app != null && atm.meta.Contains("za.co.reactor.A_TEXT"))
                        {
                            app.Description = atm.content;
                        }
 
                        if (app != null && app.End > app.Start)
                        {
                            RadScheduler1.DataStartField = app.Start.ToString();
                            RadScheduler1.DataSubjectField = app.Subject.ToString();
                            RadScheduler1.DataEndField = app.ToString();
                            RadScheduler1.DataKeyField = app.ID.ToString();
                            RadScheduler1.SelectedView = SchedulerViewType.MonthView;
                            RadScheduler1.SelectedDate = app.Start;
                            RadScheduler1.Visible = true; 

                        }
                    }


                }

            }
        }
        catch (ApplicationException ex)
        {

        }
        finally
        {
            obj.closeSession(SessionKey);

        }
 

    }


Now this Function works well and it has no problems , in the debug more, i check the value that is supplied to this function from the page method function its fine. and my JS looks like this

function keyPress() {
     var tb = document.getElementById("<%=txtsearchid%>");
     if (tb.value.length == 2) {
         PageMethods.Getadata(tb.value);
         ToggleCollapsePane();

     }
     return false;
 }


and the Toggle function

function ToggleCollapsePane() {

        var splitter = $find("RadSplitter1");

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

        if (!pane) return;

        if (pane.get_collapsed()) {
            pane.expand();
        }
        else {
            pane.collapse();

        }
    }


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 != "")
    {
        Bind_SearchBox(txtseach.Text.Trim());

    }

}


In FireFox i get this Error when i debug it
<br />
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.

Thanks
Vuyiswa Maseko,

Spoted in Daniweb-- Sorry to rant. I hate websites. They are just wierd. They don't behave like normal code.

C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
modified on Tuesday, August 10, 2010 7:05 AM

AnswerRe: Calling a Page Method In Javascript Pin
Łukasz Nowakowski10-Aug-10 0:59
Łukasz Nowakowski10-Aug-10 0:59 
GeneralRe: Calling a Page Method In Javascript Pin
Vimalsoft(Pty) Ltd10-Aug-10 1:09
professionalVimalsoft(Pty) Ltd10-Aug-10 1:09 
GeneralRe: Calling a Page Method In Javascript Pin
Łukasz Nowakowski10-Aug-10 1:29
Łukasz Nowakowski10-Aug-10 1:29 
GeneralRe: Calling a Page Method In Javascript Pin
Vimalsoft(Pty) Ltd10-Aug-10 1:34
professionalVimalsoft(Pty) Ltd10-Aug-10 1:34 
GeneralRe: Calling a Page Method In Javascript Pin
Łukasz Nowakowski10-Aug-10 1:49
Łukasz Nowakowski10-Aug-10 1:49 
GeneralRe: Calling a Page Method In Javascript [modified] Pin
Vimalsoft(Pty) Ltd10-Aug-10 4:05
professionalVimalsoft(Pty) Ltd10-Aug-10 4:05 
GeneralRe: Calling a Page Method In Javascript Pin
Łukasz Nowakowski10-Aug-10 4:36
Łukasz Nowakowski10-Aug-10 4:36 
GeneralRe: Calling a Page Method In Javascript Pin
Vimalsoft(Pty) Ltd10-Aug-10 5:01
professionalVimalsoft(Pty) Ltd10-Aug-10 5:01 
GeneralRe: Calling a Page Method In Javascript Pin
Łukasz Nowakowski10-Aug-10 8:08
Łukasz Nowakowski10-Aug-10 8:08 
GeneralRe: Calling a Page Method In Javascript Pin
Vimalsoft(Pty) Ltd10-Aug-10 20:15
professionalVimalsoft(Pty) Ltd10-Aug-10 20:15 
GeneralRe: Calling a Page Method In Javascript Pin
Łukasz Nowakowski10-Aug-10 21:29
Łukasz Nowakowski10-Aug-10 21:29 
GeneralRe: Calling a Page Method In Javascript Pin
Vimalsoft(Pty) Ltd10-Aug-10 21:55
professionalVimalsoft(Pty) Ltd10-Aug-10 21:55 
QuestionSQL Server Load Balancing with ASP.Net Pin
satsumatable9-Aug-10 20:02
satsumatable9-Aug-10 20:02 
AnswerRe: SQL Server Load Balancing with ASP.Net Pin
Mycroft Holmes9-Aug-10 21:22
professionalMycroft Holmes9-Aug-10 21:22 
AnswerRe: SQL Server Load Balancing with ASP.Net Pin
SimulationofSai10-Aug-10 15:42
SimulationofSai10-Aug-10 15:42 
QuestionGuide lines to develop a Payment Gateway in C# Pin
arun_pk9-Aug-10 19:24
arun_pk9-Aug-10 19:24 
QuestionHow often do you "Build" a project during development? Pin
Matt U.9-Aug-10 16:45
Matt U.9-Aug-10 16:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.