0

When I'm trying to double click any control in visual studio its not taking to code behind file rather its taking me to mark up code.

How I can fix it, please suggest something.

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="CSASPNETSearchEngine.Default" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Search Engine</title>
</head>
<body>
    <form id="form1" runat="server" defaultfocus="txtKeyWords">

    <p>Please input one or more keywords (separated by spaces) and then click the search button.</p>

    <!-- Search Form -->
    <asp:Label ID="lbAlert" runat="server" ForeColor="Red"></asp:Label>
    <asp:TextBox ID="tbKeyWords" runat="server"></asp:TextBox>

    <br /><br />

    <!-- Search Result -->
    <asp:Button ID="Button2" runat="server" Text="Click to show all Date" Width="255px" />
    <asp:Repeater ID="RepeaterSearchResult" runat="server">
</body>

.

using System;
using System.Collections.Generic;
using System.Linq;
using CSASPNETSearchEngine;

namespace CSASPNETSearchEngine
{
    public partial class Default : System.Web.UI.Page
    {
        /// <summary>
        /// The keywords input by user.
        /// </summary>
        protected List<string> keywords = new List<string>(); 

        protected void btnSearch_Click(object sender, EventArgs e)

enter image description here

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
xxxx
  • 57
  • 14
  • Share some code first with us. Secondly, check if the aspx page inherits the correct code-behind class. Go to aspx page and check the value of `inherits` attribute under `Page` directive. If that's ok then try to right click on your project in solution explorer and click 'Covert to web application'. – Aishwarya Shiva May 30 '15 at 13:13
  • Also, open the website (not solution or project) in another VS. Now save the project again. Everything will be perfectly linked up. – Aishwarya Shiva May 30 '15 at 13:16
  • @AishwaryaShiva I have have posted code sample. – xxxx May 30 '15 at 13:27
  • if I add code directive I get erron on line one – xxxx May 30 '15 at 13:33
  • I have added it now but still giving error on line one. Error Could not load type 'CSASPNETSearchEngine.Default'. – xxxx May 30 '15 at 13:38
  • Check that the code-behind file contains a class `Default` which must be inside the namespace `CSASPNETSearchEngine` – Aishwarya Shiva May 30 '15 at 13:42
  • it has it namespace CSASPNETSearchEngine { public partial class Default : System.Web.UI.Page – xxxx May 30 '15 at 13:43
  • Try removing `using CSASPNETSearchEngine;` from cs file. – Aishwarya Shiva May 30 '15 at 14:23
  • Also try using `CodeFile` instead of `CodeBehind`. Parser errors sometimes occurs due to this. I don't know the reason but this worked for most of askers on Stack Overflow. – Aishwarya Shiva May 30 '15 at 14:31
  • This may be cause: https://support.microsoft.com/en-us/kb/306155 This may be solution: http://stackoverflow.com/questions/73022/codefile-vs-codebehind – Grady G Cooper May 30 '15 at 14:34

0 Answers0