Skip to content

Commit 5bbbf5d

Browse files
committed
L11
1 parent e84248c commit 5bbbf5d

11 files changed

+180
-131
lines changed

11/L11/L11/About.aspx

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

11/L11/L11/About.aspx.cs

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

11/L11/L11/About.aspx.designer.cs

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

11/L11/L11/Contact.aspx

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

11/L11/L11/Contact.aspx.cs

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

11/L11/L11/L11.csproj

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@
154154
</Reference>
155155
</ItemGroup>
156156
<ItemGroup>
157-
<Content Include="About.aspx" />
158157
<Content Include="Account\AddPhoneNumber.aspx" />
159158
<Content Include="Account\Confirm.aspx" />
160159
<Content Include="Account\Forgot.aspx" />
@@ -170,7 +169,6 @@
170169
<Content Include="Account\ResetPasswordConfirmation.aspx" />
171170
<Content Include="Account\TwoFactorAuthenticationSignIn.aspx" />
172171
<Content Include="Account\VerifyPhoneNumber.aspx" />
173-
<Content Include="Contact.aspx" />
174172
<Content Include="Content\bootstrap.css" />
175173
<Content Include="Content\bootstrap.min.css" />
176174
<Content Include="Content\Site.css" />
@@ -335,23 +333,9 @@
335333
<DependentUpon>VerifyPhoneNumber.aspx</DependentUpon>
336334
</Compile>
337335
<Compile Include="App_Start\BundleConfig.cs" />
338-
<Compile Include="About.aspx.cs">
339-
<DependentUpon>About.aspx</DependentUpon>
340-
<SubType>ASPXCodeBehind</SubType>
341-
</Compile>
342-
<Compile Include="About.aspx.designer.cs">
343-
<DependentUpon>About.aspx</DependentUpon>
344-
</Compile>
345336
<Compile Include="App_Start\IdentityConfig.cs" />
346337
<Compile Include="App_Start\RouteConfig.cs" />
347338
<Compile Include="App_Start\Startup.Auth.cs" />
348-
<Compile Include="Contact.aspx.cs">
349-
<DependentUpon>Contact.aspx</DependentUpon>
350-
<SubType>ASPXCodeBehind</SubType>
351-
</Compile>
352-
<Compile Include="Contact.aspx.designer.cs">
353-
<DependentUpon>Contact.aspx</DependentUpon>
354-
</Compile>
355339
<Compile Include="Default.aspx.cs">
356340
<DependentUpon>Default.aspx</DependentUpon>
357341
<SubType>ASPXCodeBehind</SubType>
@@ -381,7 +365,6 @@
381365
<Compile Include="Startup.cs" />
382366
<Compile Include="StudentControl.ascx.cs">
383367
<DependentUpon>StudentControl.ascx</DependentUpon>
384-
<SubType>ASPXCodeBehind</SubType>
385368
</Compile>
386369
<Compile Include="StudentControl.ascx.designer.cs">
387370
<DependentUpon>StudentControl.ascx</DependentUpon>

11/L11/L11/Site.Master

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Site.master.cs" Inherits="L11.SiteMaster" %>
2-
32
<!DOCTYPE html>
43

54
<html lang="ru">

11/L11/L11/StudentControl.ascx

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
11
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="StudentControl.ascx.cs" Inherits="L08.StudentControl" %>
2-
<div ">
2+
<script type="text/javascript">
3+
function LookUpStock() {
4+
if (Page_ClientValidate()) {
5+
let list = document.getElementById("MainContent_StudentControl_RadioButtonListSex");
6+
let inputs = list.getElementsByTagName("input");
7+
let selected;
8+
for (var i = 0; i < inputs.length; i++) {
9+
if (inputs[i].checked) {
10+
selected = inputs[i];
11+
break;
12+
}
13+
}
14+
let data = JSON.stringify(
15+
{
16+
"Family": $get("MainContent_StudentControl_TextBoxFamily").value,
17+
"Name": $get("MainContent_StudentControl_TextBoxName").value,
18+
"Patro": $get("MainContent_StudentControl_TextBoxPatro").value,
19+
"Date": $get("MainContent_StudentControl_TextBoxDate").value,
20+
"Sex": selected.value,
21+
"Name": $get("MainContent_StudentControl_TextBoxName").value,
22+
"Faculty": $get("MainContent_StudentControl_DropDownListFaculty").value,
23+
"Year": Number($get("MainContent_StudentControl_TextBoxYear").value),
24+
"Group": Number($get("MainContent_StudentControl_TextBoxGroup").value)
25+
});
26+
CallServer(data, "");
27+
}
28+
return false;
29+
}
30+
function ReceiveServerData(rValue) {
31+
$get("MainContent_StudentControl_LabelResult").textContent = rValue;
32+
}
33+
</script>
34+
<asp:FormView ID="FormView1" runat="server"></asp:FormView>
35+
<div>
336
<h1>StudentInfo</h1>
437
<p>
538
<asp:TextBox ID="TextBoxFamily" runat="server" placeholder="Фамилия"></asp:TextBox>
6-
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Введите фамилию" ControlToValidate="TextBoxFamily" Display="None"></asp:RequiredFieldValidator>
739
</p>
840
<p>
941
<asp:TextBox ID="TextBoxName" runat="server" placeholder="Имя"></asp:TextBox>
@@ -15,14 +47,14 @@
1547
<asp:TextBox ID="TextBoxDate" runat="server" placeholder="Дата рождения"></asp:TextBox>
1648
</p>
1749
<p>
18-
<asp:RadioButtonList ID="RadioButtonListSex" runat="server" RepeatDirection="Horizontal" >
19-
<asp:ListItem Value="0" Text="Ж" ></asp:ListItem>
50+
<asp:RadioButtonList ID="RadioButtonListSex" runat="server" RepeatDirection="Horizontal">
51+
<asp:ListItem Value="0" Text="Ж"></asp:ListItem>
2052
<asp:ListItem Value="1" Text="М" Selected="true"></asp:ListItem>
2153
</asp:RadioButtonList>
2254
</p>
23-
24-
<p>Факультет
25-
<asp:DropDownList ID="DropDownListFaculty" runat="server" >
55+
<p>
56+
Факультет
57+
<asp:DropDownList ID="DropDownListFaculty" runat="server">
2658
<asp:ListItem Value="ИТ"></asp:ListItem>
2759
<asp:ListItem Value="ПИМ"></asp:ListItem>
2860
<asp:ListItem Value="ХТиТ"></asp:ListItem>
@@ -31,12 +63,23 @@
3163
<p>
3264
<asp:TextBox ID="TextBoxYear" runat="server" placeholder="Год поступления"></asp:TextBox>
3365
</p>
34-
<p>
66+
<p>
3567
<asp:TextBox ID="TextBoxGroup" runat="server" placeholder="Группа"></asp:TextBox>
36-
<asp:RangeValidator ID="RangeValidator1" runat="server" ErrorMessage="Группа не в диапазоне 1 100" Font-Overline="False" ControlToValidate="TextBoxGroup" MaximumValue="100" MinimumValue="1" Type="Integer" Display="None"></asp:RangeValidator>
37-
</p>
38-
<p><asp:Button ID="ButtonCancel" runat="server" Text="Отказаться" /><asp:Button ID="ButtonEnter" runat="server" Text="Ввод" />
3968
</p>
40-
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ValidationGroup="ValidGr1" />
69+
<p>
70+
<asp:Button ID="ButtonCancel" runat="server" Text="Отказаться" CausesValidation="false" UseSubmitBehavior="false" Visible="false"/>
71+
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Введите фаилию" ControlToValidate="TextBoxFamily" Display="None"></asp:RequiredFieldValidator>
72+
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Введите № группы" ControlToValidate="TextBoxGroup" Display="None"></asp:RequiredFieldValidator>
73+
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Введите Имя" ControlToValidate="TextBoxName" Display="None"></asp:RequiredFieldValidator>
74+
<asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="введите отчество" ControlToValidate="TextBoxPatro" Display="None"></asp:RequiredFieldValidator>
75+
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="Введите дату рождения" ControlToValidate="TextBoxDate" Display="None"></asp:RequiredFieldValidator>
76+
<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="Введите год поступления" ControlToValidate="TextBoxYear" Display="None"></asp:RequiredFieldValidator>
77+
<asp:CompareValidator ID="CompareValidator1" runat="server" ErrorMessage="день рождения error" Display="None" Operator="LessThan" Type="Date" ControlToValidate="TextBoxDate"></asp:CompareValidator>
78+
79+
80+
<asp:RangeValidator ID="RangeValidatorTextBoxGroup" runat="server" ErrorMessage="№ группы в диапазоне 1 100" ControlToValidate="TextBoxGroup" MaximumValue="100" MinimumValue="1" Type="Integer" Display="None"></asp:RangeValidator>
81+
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
82+
<asp:Button runat="server" ID="ButtonEnter" OnClientClick="LookUpStock();return false;" UseSubmitBehavior="false" Text="Async"/>
4183

84+
<asp:Label ID="LabelResult" runat="server" Text="Label"></asp:Label>
4285
</div>

11/L11/L11/StudentControl.ascx.cs

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using System.Text;
45
using System.Web;
56
using System.Web.UI;
67
using System.Web.UI.WebControls;
7-
8-
/*1. Разработайте пользовательский элемент управления, который содержит поля для ввода следующих данных о студенте:
9-
фамилия(textbox, string);
10-
имя (textbox, string);
11-
отчество (textbox, string);
12-
дата рождения (textbox, date);
13-
пол (radiobutton: м, ж);
14-
факультет(dropdownlist, date);
15-
группа (textbox, int);
16-
год поступления (textbox, int).
17-
Кроме того, пользовательский элемент управления должен содержать две кнопки: ввод, отказаться.
18-
*/
8+
using Newtonsoft.Json;
199

2010
namespace L08
2111
{
22-
public partial class StudentControl : System.Web.UI.UserControl
12+
public class Student
13+
{
14+
public string Family { get; set; }
15+
public string Name { get; set; }
16+
public string Patro { get; set; }
17+
public string Date { get; set; }
18+
public string Sex { get; set; }
19+
public string Faculty { get; set; }
20+
public int Year { get; set; }
21+
public int Group { get; set; }
22+
}
23+
public partial class StudentControl : System.Web.UI.UserControl, ICallbackEventHandler
2324
{
2425
public string name { get; set; }
2526
public string family { get; set; }
@@ -31,13 +32,39 @@ public partial class StudentControl : System.Web.UI.UserControl
3132
public int year { get; set; }
3233
public string buttonEnterText { get; set; }
3334
public string buttonCancelText { get; set; }
34-
35+
protected string returnValue;
3536
protected void Page_Load(object sender, EventArgs e)
3637
{
38+
CompareValidator1.ValueToCompare = DateTime.Now.ToShortDateString();
39+
//CompareValidator2.ValueToCompare = DateTime.Now.Year.ToString();
3740
if (buttonEnterText != null)
3841
ButtonEnter.Text = buttonEnterText;
39-
if(buttonCancelText!=null)
42+
if (buttonCancelText != null)
4043
ButtonCancel.Text = buttonCancelText;
44+
45+
String cbReference = Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
46+
String callbackScript = "function CallServer(arg, context)" + "{ " + cbReference + ";}";
47+
Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "CallServer", callbackScript, true);
48+
49+
}
50+
51+
public void RaiseCallbackEvent(string eventArgument)
52+
{
53+
try
54+
{
55+
Student student = JsonConvert.DeserializeObject<Student>(eventArgument);
56+
if (student != null)
57+
returnValue = "OK";
58+
}
59+
catch (Exception ex)
60+
{
61+
returnValue = ex.Message;
62+
}
63+
}
64+
65+
public string GetCallbackResult()
66+
{
67+
return returnValue;
4168
}
4269
}
4370
}

0 commit comments

Comments
 (0)