问题描述
asp:<%@PageLanguage="C#"AutoEventWireup="true"CodeBehind="login.aspx.cs"Inherits="QQLoginAouth2.login"%><!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><headrunat="server"><title>无标题页</title></head><body><formid="form1"runat="server"><divstyle="width:1366px;background:#fff"align="center"><divstyle="width:430px;border-right:1pxsolid#d9d9d9;border-left:1pxsolid#d9d9d9"><tablealign="center"><tr><td><br/><br/><br/><imgsrc="images/school/52school350200.jpg"alt=""style="height:109px;width:228px"/></td></tr><tr><tdalign="center"><asp:ImageButtonID="ImageButton2"runat="server"ImageUrl='images/school/Connect_logo_4.png'OnClick="ImageButton1_Click"Height="32px"Width="170px"/></td></tr></table></div></div></form></body></html>asp.csusingSystem;usingSystem.Text;usingSystem.Collections.Generic;usingSystem.IO;usingSystem.Data;usingSystem.Configuration;usingSystem.Collections;usingSystem.Web;usingSystem.Web.Security;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingSystem.Web.UI.WebControls.WebParts;usingSystem.Web.UI.HtmlControls;usingNewtonsoft.Json;namespaceQQLoginAouth2{publicpartialclasslogin:System.Web.UI.Page{privatereadonlystringclient_id=Utils.GetAppSeting("qzone_AppID");privatereadonlystringclient_secret=Utils.GetAppSeting("qzone_AppKey");privatereadonlystringredirect_uri=Utils.GetAppSeting("qzone_Redirect_uri");privatestringstate="";protectedvoidPage_Load(objectsender,EventArgse){}protectedvoidImageButton1_Click(objectsender,ImageClickEventArgse){state=Guid.NewGuid().ToString().Replace("-","");//Utils.WriteCookie("state",state,60);HttpContext.Current.Session["state"]=state;stringlogin_url="https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id="+client_id+"&state="+state+"&redirect_uri="+Utils.UrlEncode(redirect_uri)+"&scope=get_user_info,get_info,get_other_info";//写日志Logs.logSave("===========================================分割线=============================================");//写日志Logs.logSave("第一步:开始跳转至QQ登陆URL:"+login_url);//开始发送HttpContext.Current.Response.Redirect(login_url);}}}提示:双击ImageButton1_Click,结果无法调用cs方法编译器错误消息:CS1061:“ASP.login_aspx”不包含“ImageButton1_Click”的定义,并且找不到可接受类型为“ASP.login_aspx”的第一个参数的扩展方法“ImageButton1_Click”(是否缺少using指令或程序集引用?)源错误:行24:</td></tr>行25:行26:<tr><tdalign="center"><asp:ImageButtonID="ImageButton2"runat="server"行27:ImageUrl='images/school/Connect_logo_4.png'OnClick="ImageButton1_Click"Height="32px"行28:Width="170px"/></td></tr>
解决方案
本帖最后由 ytzhangyanghuan 于 2015-01-07 11:12:08 编辑
解决方案二:
login.aspx.cs“ASP.login_aspx”检查一下文件名吧,感觉没对应上啊
解决方案三:
不是这个问题,主要是html中的控件无法直接调用asp.cs的方法,当是我也不知道如何解决。