Skip to content

Commit 9aeaa63

Browse files
committed
L03 edit
1 parent 65c62c5 commit 9aeaa63

File tree

114 files changed

+200
-31141
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+200
-31141
lines changed

3/L03/L03/Default.aspx

Lines changed: 36 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,41 @@
22

33
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
44

5-
<div class="row">
6-
<div class="col-md-4">
7-
<h2>Getting started</h2>
8-
<p>
9-
ASP.NET Web Forms lets you build dynamic websites using a familiar drag-and-drop, event-driven model.
10-
A design surface and hundreds of controls and components let you rapidly build sophisticated, powerful UI-driven sites with data access.
11-
</p>
12-
<p>
13-
<a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301948">Learn more &raquo;</a>
14-
</p>
15-
</div>
16-
<div class="col-md-4">
17-
<h2>Get more libraries</h2>
18-
<p>
19-
NuGet is a free Visual Studio extension that makes it easy to add, remove, and update libraries and tools in Visual Studio projects.
20-
</p>
21-
<p>
22-
<a class="btn btn-default" href="http://go.microsoft.com/fwlink/?LinkId=301949">Learn more &raquo;</a>
23-
</p>
24-
</div>
5+
<script type="text/javascript">
6+
function me() {
7+
var oReq = new XMLHttpRequest();
8+
var sUrl = "http://localhost:61580/sum.vsm";
9+
oReq.open("POST", sUrl, true);
10+
oReq.onreadystatechange = function () {
11+
if (oReq.readyState == 4 && oReq.status == 200) {
12+
// alert(oReq.response);
13+
document.getElementById("TextBoxResult").value = oReq.response;
14+
}
15+
}
16+
oReq.send("param1=" + document.getElementById("TextBox1").value + "&param2=" + document.getElementById("TextBox2").value);
17+
}
18+
</script>
19+
<div>
20+
<p>
21+
<asp:Button ID="ButtonGet" runat="server" Text="Get" OnClick="ButtonGet_Click" />
22+
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
23+
</p>
24+
<p>
25+
<asp:Button ID="ButtonPost" runat="server" Text="Post" OnClick="ButtonPost_Click" />
26+
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
27+
</p>
28+
<p>
29+
<asp:Button ID="Button3" runat="server" Text="Put" OnClick="Button3_Click" />
30+
<asp:Label ID="Label3" runat="server" Text=""></asp:Label>
31+
</p>
32+
<p>
33+
<asp:Button ID="ButtonSum" runat="server" Text="Sum" OnClick="ButtonSum_Click" />
34+
<asp:TextBox ID="TextBox1" runat="server" ClientIDMode="Static"></asp:TextBox>
35+
<asp:TextBox ID="TextBox2" runat="server" ClientIDMode="Static"></asp:TextBox>
36+
<asp:TextBox ID="TextBoxResult" runat="server" ReadOnly="True" ClientIDMode="Static"></asp:TextBox>
37+
<!-- <asp:Button ID="ButtonAjax" runat="server" Text="Ajax" UseSubmitBehavior="false" ClientIDMode="Static" OnClientClick="me()" />
38+
-->
39+
<input type="button" value="Ajax" onclick="me()" id="ButtonAjax">
40+
</p>
2541
</div>
2642
</asp:Content>

3/L03/L03/Default.aspx.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
using System.Web;
55
using System.Web.UI;
66
using System.Web.UI.WebControls;
7+
using System.Net;
8+
using System.IO;
9+
using System.Text;
710

811
namespace L03
912
{
@@ -13,5 +16,67 @@ protected void Page_Load(object sender, EventArgs e)
1316
{
1417

1518
}
19+
protected void ButtonGet_Click(object sender, EventArgs e)
20+
{
21+
try
22+
{
23+
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://localhost:61580/aaa.vsm?param1=1&param2=aaa");
24+
req.Method = "GET";
25+
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
26+
StreamReader streamReader = new StreamReader(res.GetResponseStream());
27+
Label1.Text = streamReader.ReadToEnd();//Response.Write(streamReader.ReadToEnd());
28+
}
29+
catch (WebException ex)
30+
{
31+
Label1.Text += "<br/>" + ex.Status + "<br/> " + ex.Message + "<br/>" + ex.TargetSite + "<br/>" + ex.Source;
32+
}
33+
}
34+
protected void ButtonPost_Click(object sender, EventArgs e)
35+
{
36+
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://localhost:61580/aaa.vsm");
37+
req.Method = "POST";
38+
String postData = "param1=" + Int32.Parse(TextBox1.Text) + "&param2=" + Int32.Parse(TextBox2.Text);
39+
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
40+
req.ContentType = "application/x-www-form-urlencoded";
41+
req.ContentLength = byteArray.Length;
42+
Stream postDataStream = req.GetRequestStream();
43+
postDataStream.Write(byteArray, 0, byteArray.Length);
44+
postDataStream.Close();
45+
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
46+
StreamReader streamReader = new StreamReader(res.GetResponseStream());
47+
Label2.Text = streamReader.ReadToEnd();
48+
}
49+
50+
protected void Button3_Click(object sender, EventArgs e)
51+
{
52+
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://localhost:61580/aaa.vsm");
53+
req.Method = "PUT";
54+
String postData = "param1=1&param2=aaa";
55+
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
56+
req.ContentType = "application/x-www-form-urlencoded";
57+
req.ContentLength = byteArray.Length;
58+
Stream postDataStream = req.GetRequestStream();
59+
postDataStream.Write(byteArray, 0, byteArray.Length);
60+
postDataStream.Close();
61+
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
62+
StreamReader streamReader = new StreamReader(res.GetResponseStream());
63+
Label3.Text = streamReader.ReadToEnd();
64+
}
65+
66+
protected void ButtonSum_Click(object sender, EventArgs e)
67+
{
68+
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://localhost:61580/sum.vsm");
69+
req.Method = "POST";
70+
String postData = "param1=" + Int32.Parse(TextBox1.Text) + "&param2=" + Int32.Parse(TextBox2.Text);
71+
byte[] byteArray = Encoding.UTF8.GetBytes(postData);
72+
req.ContentType = "application/x-www-form-urlencoded";
73+
req.ContentLength = byteArray.Length;
74+
Stream postDataStream = req.GetRequestStream();
75+
postDataStream.Write(byteArray, 0, byteArray.Length);
76+
postDataStream.Close();
77+
HttpWebResponse res = (HttpWebResponse)req.GetResponse();
78+
StreamReader streamReader = new StreamReader(res.GetResponseStream());
79+
TextBoxResult.Text = streamReader.ReadToEnd();
80+
}
1681
}
1782
}

3/L03/L03/Default.aspx.designer.cs

Lines changed: 99 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

3/L03C/L03C.sln

Lines changed: 0 additions & 22 deletions
This file was deleted.

3/L03C/L03C/Account/AddPhoneNumber.aspx

Lines changed: 0 additions & 28 deletions
This file was deleted.

3/L03C/L03C/Account/AddPhoneNumber.aspx.cs

Lines changed: 0 additions & 34 deletions
This file was deleted.

3/L03C/L03C/Account/AddPhoneNumber.aspx.designer.cs

Lines changed: 0 additions & 33 deletions
This file was deleted.

3/L03C/L03C/Account/Confirm.aspx

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)