|
@model mvcForumapp.Models.Register
@{
ViewBag.Title = "Register";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<script type="text/jscript">
//get file size
function GetFileSize(fileid) {
try {
var fileSize = 0;
//for IE
if ($.browser.msie) {
//before making an object of ActiveXObject,
//please make sure ActiveX is enabled in your IE browser
var objFSO = new ActiveXObject("Scripting.FileSystemObject"); var filePath = $("#" + fileid)[0].value;
var objFile = objFSO.getFile(filePath);
var fileSize = objFile.size; //size in kb
fileSize = fileSize / 1048576; //size in mb
}
//for FF, Safari, Opeara and Others
else {
fileSize = $("#" + fileid)[0].files[0].size //size in kb
fileSize = fileSize / 1048576; //size in mb
}
// alert("Uploaded File Size is" + fileSize + "MB");
return fileSize;
}
catch (e) {
alert("Error is :" + e);
}
}
//get file path from client system
function getNameFromPath(strFilepath) {
var objRE = new RegExp(/([^\/\\]+)$/);
var strName = objRE.exec(strFilepath);
if (strName == null) {
return null;
}
else {
return strName[0];
}
}
$("#btnSubmit").live("click", function () {
if ($('#fileToUpload').val() == "") {
$("#spanfile").html("Please upload file");
return false;
}
else {
return checkfile();
}
});
function checkfile() {
var file = getNameFromPath($("#fileToUpload").val());
if (file != null) {
var extension = file.substr((file.lastIndexOf('.') + 1));
// alert(extension);
switch (extension) {
case 'jpg':
case 'JPG':
case 'png':
case 'PNG':
case 'gif':
case 'GIF':
flag = true;
break;
default:
flag = false;
}
}
if (flag == false) {
$("#spanfile").text("You can upload only jpg,png,gif,pdf extension file");
return false;
}
else {
var size = GetFileSize('fileToUpload');
if (size > 3) {
$("#spanfile").text("You can upload file up to 3 MB");
return false;
}
else {
$("#spanfile").text("");
}
}
}
$(function () {
$("#fileToUpload").change(function () {
checkfile();
});
});
</script>
@using (Html.BeginForm("Register", "Register", FormMethod.Post, new { enctype = "multipart/form-data" }))
{
<br />
<br />
<div class="block_wrap left" id="register_form">
<h2>
Ready to register?</h2>
<p class="extra">
It's free and simple to register for our board! We just need
a few pieces of information from you, and you'll be ready to
make your first post in no time!
<br />
If you already have an account, you can go directly to the <a
title="Go to sign in" href="../Login/Login">sign in page</a>
<br />
</p>
<div class="generic_bar">
</div>
<h3 style="text-align: center;" class="bar">
Account Information</h3>
<ul>
<li class="field required ">
@Html.LabelFor(m => m.Username)
@Html.TextBoxFor(m => m.Username, new { maxlength = 50 })
<span class="input_error">@Html.ValidationMessageFor(m => m.Username)</span>
</li>
<li class="field required ">
@Html.LabelFor(m => m.Displayname)
@Html.TextBoxFor(m => m.Displayname, new { maxlength = 50 })
<span class="input_error">@Html.ValidationMessageFor(m => m.Displayname)</span>
</li>
<li class="field required ">
@Html.LabelFor(m => m.Email)
@Html.TextBoxFor(m => m.Email, new { maxlength = 50 })
<span class="input_error">@Html.ValidationMessageFor(m => m.Email)</span>
</li>
<li class="field required ">
@Html.LabelFor(m => m.password)
@Html.PasswordFor(m => m.password, new { maxlength = 50 })
<span class="input_error">@Html.ValidationMessageFor(m => m.password)</span>
</li>
<li class="field required ">
@Html.LabelFor(m => m.PasswordConfirm)
@Html.PasswordFor(m => m.PasswordConfirm, new { maxlength = 50 })
<span class="input_error">@Html.ValidationMessageFor(m => m.PasswordConfirm)</span>
</li>
<li class="field required ">
<label>
Select Image</label>
<input type="file" id="fileToUpload" name="file" />
<span class="input_error" id="spanfile"></span></li>
</ul>
<br />
<hr />
<div style="float: left; margin-left: 250px;">
<table>
<tr>
<td>
<input type="submit" class="input_submit" id="btnSubmit" value="Create User" />
</td>
<td>
@Html.ActionLink("Cancel", "Index", new { Controller = "Technology" }, new { @class = "input_submit" })
</td>
</tr>
</table>
@*<input type="submit" value=" Cancel" class="input_submit" />*@
</div>
</div>
<br />
<div style="float: right; margin-right: 350px;">
</div>
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I am working as a Software engineer. Web development in Asp.Net with C#, WinForms and MS sql server are the experience tools that I have had for the past 3 years. Yet to work on WCF, WPF, Silverlight and other latest ones.