程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> .NET實例教程 >> 我的收藏

我的收藏

編輯:.NET實例教程

在Html中

 



<script language =Javascript >
function addFavourite(companyId,CompanyName)
...{
    thisframe.document.location.href  ="/Security/AddFavourite.ASPx?relationId="+companyId+"&relationType=company&Subject="+CompanyName+"";
    alert(tthisframe.document.location.href  );
}
</script>

<a href="Javascript:addFavourite(''&lt;%=CompanyId%&gt;'',''&lt;%=FullName%&gt;'');">收藏此公司</a><iframe id="thisframe" frameborder="0" width="0" height="0"></iframe>

在addFavourite.ASPx.cs中

 



private void Page_Load(object sender, System.EventArgs e)
        ...{
            if(Context.User.Identity.IsAuthenticated )
            ...{
                relationId=Request["relationId"];
                relationType = Request["relationType"];
                Subject=Request["Subject"];
                Tangsoft.Business.Application.Entities.FavouriteData ds=new Tangsoft.Business.Application.EntitIEs.FavouriteData();
                Tangsoft.Business.Application.Entities.FavouriteData.FavouritesRow dr=(Tangsoft.Business.Application.EntitIEs.FavouriteData.FavouritesRow)ds.Favourites.NewRow();
                dr.FavouriteId=System.Guid.NewGuid();
   dr.RelationId=new Guid(relationId);
                dr.RelationType=this.relationType.ToString();
                dr.Subject=this.Subject.ToString();
                dr.CreatedByUserId=System.Guid.NewGuid();
                dr.CreationTime=DateTime.Now;
                dr.IsDeleted=false;
                try
                ...{
                    ds.Favourites.Rows.Add(dr);
                }
                catch(Exception ex)
                ...{
                    string msg= ex.Message ;
                }
                ServiceInterfaces.FavouriteService.Save(ds);

                Page.RegisterClIEntScriptBlock("alert","<script language=Javascript>alert(''該信息已經成功加入您的收藏夾!'')</script>");
            }
            else
 ...{
                    Page.RegisterClIEntScriptBlock("alert","<script language=Javascript>alert(''請先登錄!'')</script>");
            }

            
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved