This is a migrated thread and some comments may be shown as answers.

Microsoft JScript Runtime error

3 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Satyaprakash J
Top achievements
Rank 1
Satyaprakash J asked on 28 Oct 2009, 09:07 AM
public partial class Questions : System.Web.UI.Page  
    {  
                       
        protected void Page_Load(object sender, EventArgs e)  
        {  
            if (Session["UserName"] != null)  
            {  
                if (!Page.IsPostBack)  
                {  
                    userNameLabel.Text = Session["UserName"].ToString();  
 
                    questionsRadGrid.AutoGenerateColumns = false;  
 
                    questionsRadGrid.MasterTableView.DataKeyNames = new string[] { "Id""TagName" };  
 
 
                    GridBoundColumn subjectColumn = new GridBoundColumn();  
                    questionsRadGrid.MasterTableView.Columns.Add(subjectColumn);  
                    subjectColumn.DataField = "Subject";  
                    subjectColumn.HeaderText = "Subject";  
                    subjectColumn.UniqueName = "Subject";  
 
                    GridBoundColumn descriptionColumn = new GridBoundColumn();  
                    questionsRadGrid.MasterTableView.Columns.Add(descriptionColumn);  
                    descriptionColumn.DataField = "Description";  
                    descriptionColumn.HeaderText = "Description";  
                    descriptionColumn.UniqueName = "Description";  
 
                    GridBoundColumn createDateTimeColumn = new GridBoundColumn();  
                    questionsRadGrid.MasterTableView.Columns.Add(createDateTimeColumn);  
                    createDateTimeColumn.DataField = "CreateDateTime";  
                    createDateTimeColumn.HeaderText = "Created Date Time";  
                    createDateTimeColumn.UniqueName = "CreateDateTime";  
 
                    GridBoundColumn userNameColumn = new GridBoundColumn();  
                    questionsRadGrid.MasterTableView.Columns.Add(userNameColumn);  
                    userNameColumn.DataField = "UserName";  
                    userNameColumn.HeaderText = "User Name";  
                    userNameColumn.UniqueName = "UserName";  
 
 
                    GridBoundColumn tagNameColumn = new GridBoundColumn();  
                    questionsRadGrid.MasterTableView.Columns.Add(tagNameColumn);  
                    tagNameColumn.DataField = "TagName";  
                    tagNameColumn.HeaderText = "Tag Name";  
                    tagNameColumn.UniqueName = "TagName";  
 
 
                    GridBoundColumn idColumn = new GridBoundColumn();  
                    questionsRadGrid.MasterTableView.Columns.Add(idColumn);  
                    idColumn.DataField = "Id";  
                    idColumn.HeaderText = "Id";  
                    idColumn.UniqueName = "Id";  
                      
                    //Create the detail table  
                    GridTableView gridTableView = new GridTableView(questionsRadGrid);  
 
                    questionsRadGrid.MasterTableView.DetailTables.Add(gridTableView);  
 
                    GridRelationFields gridRelationFields = new GridRelationFields();  
                    gridTableView.ParentTableRelation.Add(gridRelationFields);  
                    gridRelationFields.MasterKeyField = "Id";  
 
 
                    gridTableView.AutoGenerateColumns = false;  
 
                    GridBoundColumn answerColumn = new GridBoundColumn();  
                    gridTableView.Columns.Add(answerColumn);  
                    answerColumn.DataField = "Description";  
                    answerColumn.HeaderText = "Answer";  
                    answerColumn.UniqueName = "Answer";  
 
                    GridBoundColumn createdDateTimeColumn = new GridBoundColumn();  
                    gridTableView.Columns.Add(createdDateTimeColumn);  
                    createdDateTimeColumn.DataField = "CreatedDateTime";  
                    createdDateTimeColumn.HeaderText = "Created DateTime";  
                    createdDateTimeColumn.UniqueName = "CreatedDateTime";  
 
                    GridBoundColumn userNameColumn1 = new GridBoundColumn();  
                    gridTableView.Columns.Add(userNameColumn1);  
                    userNameColumn1.DataField = "UserName";  
                    userNameColumn1.HeaderText = "User Name";  
                    userNameColumn1.UniqueName = "UserName";  
 
 
                    GridBoundColumn questionIdColumn = new GridBoundColumn();  
                    gridTableView.Columns.Add(questionIdColumn);  
                    questionIdColumn.DataField = "QuestionId";  
                    questionIdColumn.HeaderText = "Question Id";  
                    questionIdColumn.UniqueName = "QuestionId";  
 
                    GridBoundColumn tagColumn = new GridBoundColumn();  
                    gridTableView.Columns.Add(tagColumn);  
                    tagColumn.DataField = "TagName";  
                    tagColumn.HeaderText = "Tag Name";  
                    tagColumn.UniqueName = "TagName";  
 
                      
                }  
 
            }  
            else 
            {  
                Response.Redirect("Login.aspx");  
            }  
        }  
 
        protected void exportButton_Click(object sender, EventArgs e)  
        {  
            questionsRadGrid.ExportSettings.OpenInNewWindow = true;  
            questionsRadGrid.ExportSettings.FileName = "Export";  
            questionsRadGrid.MasterTableView.ExportToExcel();  
        }  
 
        protected void questionsRadGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)  
        {  
            if (!e.IsFromDetailTable)  
            {  
                HttpClient client = new HttpClient();  
                HttpResponseMessage response = client.Get(new Uri("http://localhost/QuestionService/Service.svc/"));  
                response.Content.LoadIntoBuffer();  
 
                QuestionCollection questionCollection = response.Content.ReadAsXmlSerializable<QuestionCollection>();  
                questionsRadGrid.DataSource = questionCollection;  
 
            }  
        }  
 
 
        protected void questionsRadGrid_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)  
        {  
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;  
 
            string questionId = dataItem.GetDataKeyValue("Id").ToString();  
            string tagName = dataItem.GetDataKeyValue("TagName").ToString();  
 
            HttpClient client1 = new HttpClient();  
            HttpResponseMessage response1 = client1.Get(new Uri("http://localhost/AnswerService/Service.svc/" + questionId));  
            response1.Content.LoadIntoBuffer();  
 
            AnswerCollection answerCollection = response1.Content.ReadAsXmlSerializable<AnswerCollection>();  
 
            foreach (Answer answer in answerCollection)  
            {  
                answer.TagName = tagName;  
                answer.QuestionId = questionId;  
            }  
 
                                    
            e.DetailTableView.DataSource = answerCollection;  
              
 
        }  
 
          
    } 
 The above code results in the following error when I click on the Expand/Collapse button to get the details view

"Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Syntax error: Missing operand before '=' operator."

Please help me overcome this error. The corresponding .aspx file is as follows

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Questions.aspx.cs" Inherits="DiscussionForumTelerikUI.Questions" EnableEventValidation="false" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server">  
<script language="javascript" type="text/javascript" > 
    function RowClick(sender, eventArgs) {  
        <!--alert("Index of clicked row is " + eventArgs.get_itemIndexHierarchical());--> 
        var grid = sender;  
        var MasterTable = grid.get_masterTableView();  
        var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];  
        var idCell = MasterTable.getCellByColumnUniqueName(row, "Id");  
        var tagCell = MasterTable.getCellByColumnUniqueName(row, "TagName");  
        var id = idCell.innerHTML;  
        var tag = tagCell.innerHTML;  
        window.location = "Answers.aspx?id=" + id + "&" + "tag=" + tag;  
 
    
    }  
</script> 
    <title>Questions</title> 
    <style type="text/css">  
        .style1  
        {  
            color: #FF3300;  
        }  
        .style2  
        {  
            color: #CC6600;  
            font-family: Calibri;  
        }  
        .style3  
        {  
            font-family: Calibri;  
        }  
    </style> 
</head> 
<body style="background-color: #CCFF99">  
    <form id="form1" runat="server">  
    <div> 
      
        <h1 class="style1">  
            <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">  
            </telerik:RadScriptManager> 
        </h1> 
        <h1 class="style1">  
            <span class="style3">Welcome</span> 
            <asp:Label ID="userNameLabel" runat="server" Font-Names="Calibri"></asp:Label> 
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
            <span class="style3">  
            <href="AddQuestion.aspx">Click here to post your question</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a   
                href="Login.aspx">Logout</a></span></h1> 
        <h1 class="style2">  
            Click on a question to view its answers</h1> 
      
    </div> 
    <telerik:RadGrid ID="questionsRadGrid" runat="server" AllowPaging="True"   
        AllowSorting="True" GridLines="None" Skin="Telerik" PageSize="50"   
        Font-Names="Calibri" Font-Size="Large" OnDetailTableDataBind="questionsRadGrid_DetailTableDataBind" OnNeedDataSource="questionsRadGrid_NeedDataSource">   
         
       <ClientSettings AllowColumnsReorder="True">  
        <ClientEvents OnRowClick="RowClick" /> 
          
            <Selecting AllowRowSelect="True" /> 
        </ClientSettings> 
          
    </telerik:RadGrid> 
      
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">  
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="questionsRadGrid">  
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="questionsRadGrid" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
 
    <asp:Button ID="exportButton" runat="server" Font-Names="Calibri"   
        onclick="exportButton_Click" Text="Export to Excel" /> 
    </form> 
</body> 
</html> 
 

Thanks
Satyaprakash J

3 Answers, 1 is accepted

Sort by
0
Johny
Top achievements
Rank 1
answered on 02 Nov 2009, 08:39 AM
Hi Satyaprakash,

From your code I see that you AJAX-ify the grid through radAjaxManager. Maybe you can try to use a standard MS updatePanel to verify whether the issue is caused by the manager or by something in your code.

Thanks Johny



0
Nishant
Top achievements
Rank 1
answered on 02 Sep 2013, 12:22 PM

Hi Johny,

I am also facing this problem , Please help me out to resolve the issue as I used RadGrid several times and use the RadAjaxManager to ajaxify the grid, but when I implement RagGrid Hierarchical only then I am facing this problem.

Thanks
Nishant Mittal
0
Radoslav
Telerik team
answered on 05 Sep 2013, 07:05 AM
Hello Nishant,

Base on the provided information it is hard to say what is causing the described issue. Could you please post your aspx page markup with the related code behind file? Thus we will be able to gather more details about your scenario and provide you mote to the point answer.

Looking forward for your reply.

Sincerely yours,
Radoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Grid
Asked by
Satyaprakash J
Top achievements
Rank 1
Answers by
Johny
Top achievements
Rank 1
Nishant
Top achievements
Rank 1
Radoslav
Telerik team
Share this question
or