1.遇到500error
(1)黃頁打開如果還是500錯誤,就要檢查webconfig是不是有問題。
(2)黃頁測試:可以打開黃頁後故意找一頁正常頁面,改壞它看有沒有出黃
頁。https://eristest.utrust.com.tw/dispCore
2.如果遇到平常寫法怎麼改都改不動程式,可以先將程式改壞掉,或全註解,
看看是否正常,有可能是生命週期造成的(網頁堆疊的方法有關)
1.建立分支
2.分支切換
在D槽下我有MyProject的資料夾,裡面的NewProject是專案所在位置,所 以在cmd地方,可以直接下git checkout main 回到主分支,左上角打勾代表成功切回,也可以透過左上角迴轉箭頭去切換分支。
1.取得click後的內容和類別名稱
<h2 class="title">標題內容</h2> <script> const title=document.querySelector(".title"); title.addEventListener("click",function(e){ console.log(e.target.textContent); //取得標題內容
console.log(e.target.getAttribute("class")); //取得類別名稱 }) </script>
1.在區塊放入html元素字串 有<div id='cards'></div>
js:
document.queryselect('#cards').innerHTML='<p>文字</p>';
jquery:
$('#cards').html('<p>文字</p>');
1.json.html語法
<!DOCTYPE html>
<head >
<title>JSON</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body>
<H5>Hwllo World</H5>
<script>
$.ajax({
url: "json.ashx",
data: {"id":"0125","name":"Tina"},
type: "POST",
dataType: "json",
success: function(returnData){
console.log(returnData);
},
error: function(xhr, ajaxOptions, thrownError){
console.log(xhr.status);
console.log(thrownError);
}
});
</script>
</body>
</html>
2.json.aspx語法code behind要有json.aspx.cs就不放上
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Template.aspx.cs" Inherits="Template" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
<title>Ch2</title>
<title>Bootstrap Navigation Bar</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<body >
<h1>This is Empty</h1>
<form runat="server">
</form>
<script>
$.ajax({
url: "json.ashx",
data: {"id":"0125","name":"Tina"},
type: "POST",
dataType: "json",
success: function(returnData){
console.log(returnData);
},
error: function(xhr, ajaxOptions, thrownError){
console.log(xhr.status);
console.log(thrownError);
}
});
</script>
</body>
</html>
3.調用json.ashx的API
<%@ WebHandler Language = "C#" Class = "ResponseOds" %> using System; using System.Web; using System.Collections.Generic; using System.IO; using System.Web.Script.Serialization; using Newtonsoft.Json; public class ResponseOds : IHttpHandler { public void ProcessRequest (HttpContext context) { string id=context.Request["id"]; //接到前端傳來值 if(id=="0125") //判斷是0125的值,在將相對應要回傳值丟到前台 { List<Student> lstStuModel = new List<Student>() { new Student(){ID=1,Name="張飛",Age=250,Sex="男"}, new Student(){ID=2,Name="潘金蓮",Age=300,Sex="女"} }; //Newtonsoft.Json序列化 string jsonData = JsonConvert.SerializeObject(lstStuModel); context.Response.ContentType = "application/json"; //回傳json格式 context.Response.Charset = "utf-8"; context.Response.Write(jsonData); } } public bool IsReusable { get { return false; } } class Student { public int ID { get; set; } public string Name { get; set; } public int Age { get; set; } public string Sex { get; set; } }參考資料 (1).(2).(3).