-
Notifications
You must be signed in to change notification settings - Fork 0
/
About.aspx
229 lines (184 loc) · 8.38 KB
/
About.aspx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<%@ Register Tagprefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<%@ Page Title="About" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="WebFormVueExample.About" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server" >
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js" type="text/javascript"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<%-- Below Production Mode --%>
<%--<script src="https://unpkg.com/[email protected]/dist/vue.global.prod.js"></script> --%>
<h2>See the code in the About Form</h2>
<br />
<%-- App 1 --%>
<div id="app">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Application 1</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" v-model="user.name" placeholder="Name">
</div>
<div class="form-group">
<label for="lastName">Last Name</label>
<input type="text" class="form-control" v-model="user.lastName" placeholder="Last Name">
</div>
</div>
<div class="col-md-6">
<div>
<label>Example: Two Way Data Binding + Interpolation:</label>
{{user.name + ' ' + user.lastName}}
</div>
<div>
<label>v-for Example:</label>
<li v-for="item in users">{{ item }}
</li>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<button type="submit" class="btn btn-primary" @click ="addUser" onclick='return false;' >Submit</button>
<button type="submit" class="btn btn-default" @click ="resetUser" onclick='return false;' >Clear</button>
<button type="submit" class="btn btn-default" @click ="clearUsersList" onclick='return false;' >Reset the List</button>
</div>
</div>
<hr />
<div class="row">
<div class="col-md-6">
<label>Example SharedVariable:</label>
<input type="text" class="form-control" v-model="sharedVariable" placeholder="Input Shared Variable">
</div>
<div class="col-md-6">
<b>Shared Variable between Apps:</b> {{sharedVariable}}
</div>
</div>
<hr />
<div class="row">
<div class="col-md-3">
<label>DropDown:</label>
<%-- <select v-model="dropDownSelectedItem" class="form-control">
<option value="1">Gerald</option>
<option value="2">Edwin</option>
<option value="3">Kelvin</option>
</select>--%>
<asp:DropDownList ID="nameDropDownList" class="form-control"
AutoPostBack="false"
v-model="dropDownSelectedItem"
runat="server" >
<asp:ListItem Value="1"> Gerald </asp:ListItem>
<asp:ListItem Value="2"> Edwin </asp:ListItem>
<asp:ListItem Value="3"> Kelvin </asp:ListItem>
</asp:DropDownList>
</div>
<div class="col-md-3">
<label>V-IF Example:</label>
<br />
<label v-if="dropDownSelectedItem == '1'">Gerald</label><label v-if="dropDownSelectedItem == '2'">Edwin</label><label v-if="dropDownSelectedItem == '3'">Kelvin</label>
</div>
<div class="col-md-3">
<b>Computed Example:
<br />
{{dropDownSelectionComputedExample}}</b>
</div>
<div class="col-md-3">
<b>Watch Example: Will trigger an alert when Selected Value is 3: Kelvin</b>
<div v-show="triggerAlertIfDropDownSelectionIsKelvin" class="alert alert-success" role="alert">Hello Kelvin!! example: v-show directive with computed property</div>
</div>
</div>
</div>
</div>
</div>
<%-- App 2 --%>
<div id="app2">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Application 2 - Example Share Reactive Data Between Vue Apps</h3>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-6">
<b>Shared Variable between Apps:</b> {{sharedVariable}}
</div>
<div class="col-md-6">
</div>
</div>
</div>
</div>
</div>
<script>
//Vue Initialization
const { createApp, ref, computed, reactive, watch } = Vue;
// Ref Attribute for reactivity and shared data between vue apps
const sharedVariable = ref('');
</script>
<%-- APP 1 --%>
<script>
//Things to Add:
// 1 - Try to create a main and also childs components.
// 2 - Example of partial views
const app = createApp({
setup() {
//#region Example reactivity (Models/properties)
const user = reactive({
name: '',
lastName: ''
});
const users = ref([]);
const dropDownSelectedItem = ref('')
//#endregion
//#region Methods
const addUser = () => {
users.value.push(user.name + ' ' + user.lastName);
resetUser();
};
const clearUsersList = () => {
users.value = [];
};
const resetUser = () => {
user.name = "";
user.lastName = "";
}
//#endregion
//#region Example Computed
const dropDownSelectionComputedExample = computed(() => {
return dropDownSelectedItem.value == '1' ? 'Gerald' : dropDownSelectedItem.value == '2' ? 'Edwin' : dropDownSelectedItem.value == '3' ? 'Kelvin' : null;
})
const triggerAlertIfDropDownSelectionIsKelvin = computed(() => {
return dropDownSelectedItem.value === '3'
});
//#endregion
//#region Example Watch
watch(dropDownSelectedItem, async (newDropDownSelectedItem, oldSDropDownSelectedItem) => {
if (newDropDownSelectedItem === "3")
alert("Watch Example: The selected Item was Kelvin!")
})
//#endregion
return {
user,
users,
dropDownSelectedItem,
sharedVariable,
addUser,
clearUsersList,
resetUser,
dropDownSelectionComputedExample,
triggerAlertIfDropDownSelectionIsKelvin,
}
}
});
app.mount("#app");
</script>
<%-- APP 2 --%>
<script>
const app2 = createApp({
setup() {
return {
sharedVariable
}
}
});
app2.mount("#app2");
</script>
</asp:Content>