Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

Accessing a datalist control from a jquery Ajax static WebMethod inside content page

$
0
0

I am creating an exam portal web application. In the exam page i have a datalist which will be displaying the question and multiple options. There is a jquery timer and an end button. If the user press end button or if the time expires the click event should get fired.

The ajax call

$.ajax({
                         type: "POST",
                         url: 'mypage.aspx/ajxCall',
                         data: "",
                         contentType: "application/json; charset=utf-8",
                         dataType: "json",
                         success: function (msg) {$("#divResult").html("success");
                         },
                         error: function (e) {$("#divResult").html("Something Wrong.");
                         }
                     });

The webmethod

[WebMethod]
    public static void ajxCall()
    {
      //do something
    }

End button click event

foreach (DataListItem item in dtlQuestions.Items)
        {
            string useranswer = "Z";
            RadioButtonList rdbl = (RadioButtonList)item.FindControl("rdbQuestions");
            HiddenField hdf = (HiddenField)item.FindControl("cans");
            switch (rdbl.SelectedIndex)
            {
               //

            }
            if (hdf.Value == useranswer)
            {
              //
            }
        }
    

Here dtlQuestions is my asp data list control.

<asp:DataList ID="dtlQuestions" runat="server" DataKeyField="vQuestion_Id"  RepeatLayout="Flow" OnItemDataBound="dtlQuestions_ItemDataBound">

Now how can I achieve my requirement of calling this button click from webmothod when time expires?

I tried

mypage ob = new mypage();
ob.btnEnd_Click(null, null); 

But failed. I also tried to put the statements of button click event directly inside my static webmethod. But I get Object reference not set to an instance of an object error.

Can you please help me.

Thanks in advance

 


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>