Click here to Skip to main content
15,908,173 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
hi,
I am getting an error "Microsoft JScript runtime error: Object expected"

In view:
C#
@{
    string id = "0";
    if (ViewData["rid"] != null)
    {
        id = ViewData["rid"].ToString();
    }

    string[] str = { "All", "Price Above 500", "Price Below 500" };
    if (id == "0")
    {
    @Html.RadioButton("RId", 0, true) @str[0].ToString();
    @Html.RadioButton("RId", 1) @str[1].ToString();
    @Html.RadioButton("RId", 2) @str[2].ToString();
    }
    else if (id == "1")
    {
    @Html.RadioButton("RId", 0) @str[0].ToString();
    @Html.RadioButton("RId", 1, true) @str[1].ToString();
    @Html.RadioButton("RId", 2) @str[2].ToString();
    }
    else
    {
    @Html.RadioButton("RId", 0) @str[0].ToString();
    @Html.RadioButton("RId", 1) @str[1].ToString();
    @Html.RadioButton("RId", 2, true) @str[2].ToString();
    }
}

<script type="text/javascript">
    $(':radio[name=RId]').change(function () {
        var value = $(this).val();
        window.location = "/Registration/ComputerScienceBooks/" + value.toString(); 
    });
</script>

In controller:
C#
public ActionResult ComputerScienceBooks(string id)
        {
            ViewData["rid"] = id;
            DataTable dt = new DataTable();
            if (id == null)
            {
                dt = registerDAL.BookDetails("Computer Science", "0");
            }
            else
            {
                dt = registerDAL.BookDetails("Computer Science", id);
            }
            if (dt.Rows.Count == 0)
            {
                ViewBag.emptyMessage = "No Book Available";
            }
            return View(ConvertDataTabletoIEnumerable(dt));
        }
Posted
Updated 22-Jul-13 20:09pm
v3
Comments
Ron Beyer 23-Jul-13 2:07am    
On what line?
harshal7689 23-Jul-13 2:24am    
Try to run this code in Internet Explore Browser.
using this u will get the exact line and number of error.
Jameel VM 23-Jul-13 5:09am    
please make sure that the page has imported the jQuery plugin

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900