I want to ask how to insert multiple rows of data at once. I included the textboxes for the user to input but it only inserts the first row of data and not the second line. Here are my references below.
The first is my controller code and the second is my view page code. I am a new coder and i need to seek help for my school work. It would be best if I can solve this problem. Thank you
[HttpPost("Create2")]
public async Task<IActionResult> CreateDependent2(Dependent dependentModel)
{
if (!ModelState.IsValid)
{
return BadRequest("Parameter condition(s) are not met");
}
else if (ModelState.IsValid)
{
_context.Dependents.Add(dependentModel);
await _context.SaveChangesAsync();
return Ok(dependentModel);
}
else
{
return BadRequest("Invalid");
}
}
and here is my view code
#model TTSH_ALIVE.Models.Dependent
#using TTSH_ALIVE.ModelObjects
#{ ViewData["Title"] = "Register";
Layout = null; }
<head>
<title>Welcome - TTSH SteWARdS</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="~/images/icons/favicon.ico" />
<link rel="stylesheet" type="text/css" href="~/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="~/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="~/fonts/Linearicons-Free-v1.0.0/icon-font.min.css">
<link rel="stylesheet" type="text/css" href="~/vendor/animate/animate.css">
<link rel="stylesheet" type="text/css" href="~/vendor/css-hamburgers/hamburgers.min.css">
<link rel="stylesheet" type="text/css" href="~/vendor/select2/select2.min.css">
<link rel="stylesheet" type="text/css" href="~/css/util.css">
<link rel="stylesheet" type="text/css" href="~/css/main.css">
</head>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100 p-t-50 p-b-0">
<span class="login100-form-error p-t-20 p-b-45">
#ViewBag.error
</span>
<div class="jp-container" style="margin-top:20px">
<h1 class="jp-jumbo"><b>Sign Up</b></h1>
<hr style="width:80px; border:5px solid #a6192e" class="jp-round">
</div>
<div class="jp-row">
<form asp-action="CreateDependent">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<input type="hidden" asp-for="UserID" value="#ViewData["UserID"]" class="form-control" />
<div class="form-group-half">
<label asp-for="AgeOfDependent" class="text-white"></label>
<input asp-for="AgeOfDependent" class="form-control" />
<span asp-validation-for="AgeOfDependent" class="text-white"></span>
</div>
<div class="form-group-full">
<label asp-for="DependentType" class="text-white"></label><br />
<select asp-for="DependentType" class="jp-select">
<option selected disabled>---Please select a dependent type---</option>
<option>Parent</option>
<option>Child</option>
</select>
<span asp-validation-for="DependentType" class="text-white"></span>
</div>
<div class="form-group-half">
<label asp-for="AgeOfDependent" class="text-white"></label>
<input asp-for="AgeOfDependent" class="form-control" />
<span asp-validation-for="AgeOfDependent" class="text-white"></span>
</div>
<div class="form-group-full">
<label asp-for="DependentType" class="text-white"></label><br />
<select asp-for="DependentType" class="jp-select">
<option selected disabled>---Please select a dependent type---</option>
<option>Parent</option>
<option>Child</option>
</select>
<span asp-validation-for="DependentType" class="text-white"></span>
</div>
<div class="text-white">
<b>#ViewBag.message</b>
</div>
<div class="form-group-half">
<input type="submit" value="Sign Up" class="jp-btn-86" />
</div>
<div class="form-group-half">
<a asp-area="" asp-controller="Login" asp-action="Index" style="margin-top: 7px" class="login100-form-btn">Back to Login</a>
</div>
</form>
</div>
</div>
</div>
#section Scripts {
#{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
Related
I am currently doing a sign-up page and i would like to insert data ( 1 page for 1 table )
After inserting data into the first table and generating the uid, i would like to bring over the generated uid to the next page.I tried to bring over the userid with viewbag on the textbox on the next page. However i end up with 0000-0000-0000-0000 instead. Can i seek some help?
My references are below.
[HttpPost]
public async Task<IActionResult> CreateAccounts(UserDTO userDto)
{
if (!ModelState.IsValid)
{
ViewBag.message = "Form is invalid please check again.";
return View("~/Views/Login/Register.cshtml");
}
string url = BaseUrl + "/User/Dto/" + "Create";
UserModel recievedUserModel = new UserModel();
#region Salting and hashing
byte[] salt = new byte[128 / 8];
using (var rng = RandomNumberGenerator.Create())
{
rng.GetBytes(salt);
}
// derive a 256-bit subkey (use HMACSHA1 with 10,000 iterations)
string hashed = Convert.ToBase64String(KeyDerivation.Pbkdf2(
password: userDto.Password,
salt: salt,
prf: KeyDerivationPrf.HMACSHA256,
iterationCount: 10000,
numBytesRequested: 256 / 8));
#endregion
userDto.Salt = salt;
userDto.Password = hashed;
StringContent content = new StringContent(JsonConvert.SerializeObject(userDto), Encoding.UTF8, "application/json");
using (var httpClient = new HttpClient())
{
using var response = await httpClient.PostAsync(url, content);
string apiResponse = await response.Content.ReadAsStringAsync();
if (response.IsSuccessStatusCode)
{
recievedUserModel = JsonConvert.DeserializeObject<UserModel>(apiResponse);
ViewBag.message = userDto.UserID;
}
else if (!response.IsSuccessStatusCode)
{
ViewBag.message = apiResponse;
}
}
return View("~/Views/Login/Register2.cshtml");
}
[HttpPost("Dto/Create")]
public async Task<IActionResult> CreateUserFromUserDto(UserDTO userDto)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
UserModel userModel = new UserModel();
if (!_context.User.Any(u => u.Username.Equals(userDto.Username)))
{
userModel = new UserModel()
{
AccessLevel = userDto.AccessLevel,
Username = userDto.Username,
Password = userDto.Password,
Salt = userDto.Salt,
Surname = userDto.Surname,
GivenName = userDto.GivenName,
ContactNo = userDto.ContactNo,
Gender = userDto.Gender,
Email = userDto.Email,
YearOfBirth = userDto.YearOfBirth
};
try
{
_context.User.Add(userModel);
await _context.SaveChangesAsync();
return Ok();
}
catch
{
return BadRequest("Unable to save to database.");
}
}
else
{
return BadRequest("Username exists, try a different username.");
}
}
Here is my HTML code
#model TTSH_ALIVE.DTOs.UserDTO
#using TTSH_ALIVE.ModelObjects
#{ ViewData["Title"] = "Register";
Layout = null; }
<head>
<title>Welcome - TTSH SteWARdS</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="~/images/icons/favicon.ico" />
<link rel="stylesheet" type="text/css" href="~/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="~/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="~/fonts/Linearicons-Free-v1.0.0/icon-font.min.css">
<link rel="stylesheet" type="text/css" href="~/vendor/animate/animate.css">
<link rel="stylesheet" type="text/css" href="~/vendor/css-hamburgers/hamburgers.min.css">
<link rel="stylesheet" type="text/css" href="~/vendor/select2/select2.min.css">
<link rel="stylesheet" type="text/css" href="~/css/util.css">
<link rel="stylesheet" type="text/css" href="~/css/main.css">
</head>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100 p-t-50 p-b-0">
<span class="login100-form-error p-t-20 p-b-45">
#ViewBag.error
</span>
<div class="jp-container" style="margin-top:20px">
<h1 class="jp-jumbo"><b>Sign Up</b></h1>
<hr style="width:80px; border:5px solid #a6192e" class="jp-round">
</div>
<div class="jp-row">
<form asp-action="CreateAccounts">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
#*<div class="form-group">
<label asp-for="UserID" class="control-label"></label>
<input asp-for="UserID" class="form-control" />
<span asp-validation-for="UserID" class="text-danger"></span>
</div>*#
<div class="form-group-full">
<label asp-for="Username" class="text-white"></label>
<input asp-for="Username" class="form-control" />
<span asp-validation-for="Username" class="text-white"></span>
</div>
<div class="form-group-full">
<label asp-for="Password" class="text-white"></label>
<input asp-for="Password" class="form-control" type="password" />
<span asp-validation-for="Password" class="text-white"></span>
</div>
<div class="form-group-half">
<label asp-for="GivenName" class="text-white"></label>
<input asp-for="GivenName" class="form-control" />
<span asp-validation-for="GivenName" class="text-white"></span>
</div>
<div class="form-group-half">
<label asp-for="Surname" class="text-white"></label>
<input asp-for="Surname" class="form-control" />
<span asp-validation-for="Surname" class="text-white"></span>
</div>
<div class="form-group-full">
<label asp-for="Gender" class="text-white"></label><br />
<select asp-for="Gender" class="jp-select">
<option selected disabled>---Please select a gender---</option>
<option>Male</option>
<option>Female</option>
<option>Others</option>
</select>
<span asp-validation-for="Gender" class="text-white"></span>
</div>
<div class="form-group-full">
<label asp-for="ContactNo" class="text-white"></label>
<input asp-for="ContactNo" class="form-control" />
<span asp-validation-for="ContactNo" class="text-white"></span>
</div>
<div class="form-group-full">
<label asp-for="Email" class="text-white"></label>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-white"></span>
</div>
<div class="form-group-full">
<label asp-for="YearOfBirth" class="text-white"></label>
<input asp-for="YearOfBirth" class="form-control" />
<span asp-validation-for="YearOfBirth" class="text-white"></span>
</div>
<div class="text-white">
<b>#ViewBag.message</b>
</div>
<div class="form-group-half">
<input type="submit" value="Sign Up" class="jp-btn-86" />
</div>
<div class="form-group-half">
<a asp-area="" asp-controller="Login" asp-action="Index" style="margin-top: 7px" class="login100-form-btn">Back to Login</a>
</div>
</form>
</div>
</div>
</div>
#section Scripts {
#{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
2nd page
#model TTSH_ALIVE.Models.Dependent
#using TTSH_ALIVE.ModelObjects
#{ ViewData["Title"] = "Register";
Layout = null; }
<head>
<title>Welcome - TTSH SteWARdS</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" type="image/x-icon" href="~/images/icons/favicon.ico" />
<link rel="stylesheet" type="text/css" href="~/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="~/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="~/fonts/Linearicons-Free-v1.0.0/icon-font.min.css">
<link rel="stylesheet" type="text/css" href="~/vendor/animate/animate.css">
<link rel="stylesheet" type="text/css" href="~/vendor/css-hamburgers/hamburgers.min.css">
<link rel="stylesheet" type="text/css" href="~/vendor/select2/select2.min.css">
<link rel="stylesheet" type="text/css" href="~/css/util.css">
<link rel="stylesheet" type="text/css" href="~/css/main.css">
</head>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100 p-t-50 p-b-0">
<span class="login100-form-error p-t-20 p-b-45">
#ViewBag.error
</span>
<div class="jp-container" style="margin-top:20px">
<h1 class="jp-jumbo"><b>Sign Up</b></h1>
<hr style="width:80px; border:5px solid #a6192e" class="jp-round">
</div>
<div class="jp-row">
<form asp-action="CreateAccounts">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group-full">
<label asp-for="UserID" class="text-white"></label>
<input asp-for="UserID" value="#ViewBag.message" class="form-control" />
<span asp-validation-for="UserID" class="text-white"></span>
</div>
<div class="form-group-half">
<label asp-for="AgeOfDependent" class="text-white"></label>
<input asp-for="AgeOfDependent" class="form-control" />
<span asp-validation-for="AgeOfDependent" class="text-white"></span>
</div>
<div class="form-group-half">
<label asp-for="DependentType" class="text-white"></label>
<input asp-for="DependentType" class="form-control" />
<span asp-validation-for="DependentType" class="text-white"></span>
</div>
<div class="text-white">
<b>#ViewBag.message</b>
</div>
<div class="form-group-half">
<input type="submit" value="Sign Up" class="jp-btn-86" />
</div>
<div class="form-group-half">
<a asp-area="" asp-controller="Login" asp-action="Index" style="margin-top: 7px" class="login100-form-btn">Back to Login</a>
</div>
</form>
</div>
</div>
</div>
#section Scripts {
#{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
I have two models Doctor and Patients.
I want to display Names of doctors in a dropdown/select in form for patients.
This is how my Patients Create View Looks like:
#model Application.Models.Patient
#model List<Application.Models.Doctor>
#addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
<link href="~/lib/twitter-bootstrap/css/bootstrap.css" rel="stylesheet" />
<script src="~/lib/jquery/jquery.js"></script>
<script src="~/lib/jquery-validate/jquery.validate.js"></script>
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.js"></script>
<link href="~/css/StyleSheet.css" rel="stylesheet" />
#{
ViewData["Title"] = "Create";
}
<html>
<head>
<meta name="viewport" content="width=device-width" />
<link href="~/lib/twitter-bootstrap/css/bootstrap.css" rel="stylesheet" />
<title>#ViewBag.Title</title>
</head>
<body>
<div class="container-fluid">
<div class="sidebar">
<nav class="nav flex-column">
<a asp-controller="Home" asp-action="Index" class="nav-item nav-link">Home</a>
<a asp-controller="Home" asp-action="Create" class="nav-item nav-link">Add User</a>
<a asp-controller="Home" asp-action="All" class="nav-item nav-link">All User</a>
</nav>
</div>
<div class="area card">
<div class="card-body" style="background-color: aqua">
<form asp-action="Create" asp-controller="Patient" method="post">
<div class="form-group">
<label asp-for="Name">Patient Name</label>
<div>
<span asp-validation-for="Name" style="color: red;"></span>
</div>
<input asp-for="Name" class="form-control" type="text" id="Name" name="Name" />
</div>
<div class="form-group">
<label asp-for="Adress">Address</label>
<div>
<span asp-validation-for="Adress" style="color: red;"></span>
</div>
<input asp-for="Adress" class="form-control" type="text" id="Adress" name="Adress" />
</div>
<div class="form-group">
<label asp-for="BloodGroup">Blood Group</label>
<select asp-for="BloodGroup" class="custom-select">
<option selected>Custom Select Menu</option>
<option value="A+">A+</option>
<option value="A-">A-</option>
<option value="B+">B+</option>
<option value="B-">B-</option>
<option value="AB+">AB</option>
</select>
</div>
<div class="form-group">
<label asp-for="BloodGroup">Blood Group</label>
#{
<select asp-for="BloodGroup" class="custom-select">
#foreach(var d in ViewBag.doc)
{
<option value="">#d.FirstName</option>
}
</select>
}
</div>
<button class="btn btn-block btn-primary" type="submit">Submit</button>
</form>
</div>
</div>
</div>
</body>
</html>
i am not able to add two models in a single view. I get an warning "the 'model' directive may only occur once per document"
I tried passing, List of Doctors in View as ViewBag but it din't help.
[HttpGet]
public IActionResult Create()
{
ApplicationContext application = new ApplicationContext();
List<Doctor> doctor = application.Doctor.ToList();
ViewBag.Doc = doctor;
return View();
}
What am i missing ? Please help me.
Google Material design is not working in asp.net.
I added whole thing all files and scripts. but still not working.
what should I add any extra thing, help me please.
css:
<link href="css/bootstrap-material-design.min.css" rel="stylesheet" />
<link href="css/roboto.min.css" rel="stylesheet" />
<link href="css/roboto.css" rel="stylesheet" />
<link href="css/ripples.min.css" rel="stylesheet" />
<link href="css/ripples.css" rel="stylesheet" />
<link href="css/material.min.css" rel="stylesheet" />
<link href="css/material.css" rel="stylesheet" />
<link href="css/material-fullpalette.min.css" rel="stylesheet" />
<link href="css/material-fullpalette.css" rel="stylesheet" />
<link href="css/jquery-ui.min.css" rel="stylesheet" />
<link href="css/bootstrap.min.css" rel="stylesheet"/>
<div class="navbar navbar-warning">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-warning-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="javascript:void(0)">Brand</a>
</div>
<div class="navbar-collapse collapse navbar-warning-collapse">
<ul class="nav navbar-nav">
<li class="active">Active</li>
<li>Link</li>
<li class="dropdown">
<a href="bootstrap-elements.html" data-target="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown
<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li class="dropdown-header">Dropdown header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left">
<div class="form-group">
<input type="text" class="form-control col-md-8" placeholder="Search">
</div>
</form>
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<li class="dropdown">
<a href="bootstrap-elements.html" data-target="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown
<b class="caret"></b></a>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
script:
<script src="js/ripples.min.js"></script>
<script src="js/ripples.js"></script>
<script src="js/npm.js"></script>
<script src="js/material.min.js"></script>
<script src="js/material.js"></script>
<script src="js/jquery.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/bootstrap.min.js"></script>
Please follow this order:
<script src="js/jquery.min.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/material.min.js"></script>
<script src="js/ripples.min.js"></script>
<script src="js/npm.js"></script>
This question already has answers here:
WebBrowser DocumentCompleted event fired more than once
(4 answers)
Closed 7 years ago.
I have a button that has the following code
webbrowser1.Navigate(testURL);
In my event handler
private void webbrowser1_Browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
if (e.Url.Equals(psyncBrowser.Url))
{
Console.WriteLine("Now it is really done");
MessageBox.Show("Loaded " + psyncBrowser.Url);
webbrowser1.Stop();
}
}
The console message is printed out four times!
What's happening, and how can I stop this?
I looked at that link before and it did not address my concern.
The site I am trying to use does not have any FRAMES or IFRAMES. I checked the HTML several times.
FUll HTML of Page below
<!DOCTYPE html>
<html>
<head>
<title>Hitachi ID Identity and Access Management Suite: Verify password</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="expires" content="-1">
<meta http-equiv="cache-control" content="private,no-cache,no-store,maxage=0,s-maxage=0,must-revalidate,proxy-revalidate,no-transform">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<script type="text/javascript">
// <![CDATA[
// Array of fields to process and attempt to focus on page load
document.focusFields = [ "_MYPW", null ];
// ]]>
</script>
<link rel="stylesheet" type="text/css" media="all" href="docs/default/css/style.css?3242224743"><!--[if lte IE 8]><link rel="stylesheet" type="text/css" media="all" href="docs/default/css/style-ie8.css?3242224743" /><![endif]-->
<!--[if lte IE 7]><link rel="stylesheet" type="text/css" media="all" href="docs/default/css/style-ie7.css?3242224743" /><![endif]-->
<!--[if lte IE 6]><link rel="stylesheet" type="text/css" media="all" href="docs/default/css/style-ie6.css?3242224743" /><![endif]-->
<script src="docs/default/js/en-US/lang.js?3242224743" type="text/javascript">
</script>
<script id="C_AUTHCHAIN_LOGIN:default:en-US:" src="docs/default/js/scripts.js?3242224743" type="text/javascript">
</script>
</head>
<body class="default noSide">
<a name="top" id="top"></a>
<form name="theform" method="post" action="psf.exe" autocomplete="off" id="theform">
<div id="container">
<span id="topMargin"><input id="TRANSACTION" name="TRANSACTION" type="hidden" value="C_AUTHCHAIN_LOGIN"> <!-- 81A84EBD-2CE5-4794-8341-E1828711FFBC -->
<input id="SESSDATA" name="SESSDATA" type="hidden" value="{AES}EIDgCtlm1WIHTuwgStamCgi1cvi98CgOIhXUvVy7N2o3jDv6ce5qxqTFLdgzyU+QYBoq5w064mzb174I2rLVeq1HT8Z+hzi78gSMPbDzX0CBy0/GVTAfFsXk4OR6hc/e"> <input id="SESSLENGTH" name="SESSLENGTH" type="hidden" value="600"> <input id="SKIN" name="SKIN" type="hidden" value="default"> <input id="LANG" name="LANG" type="hidden" value="en-US"> <input id="JS" name="JS" type="hidden" value="false"> <input disabled="disabled" id="currentDateTime" type="hidden" value="2015-04-22 08:05:08 "> <input alt="" class="hideIfJs" id="DEFAULT_PAGE_ACTION" name="DEFAULT_UNUSED_BUTTON.x" src="docs/pics/spacer.gif" style="border: none; height: 1px; width: 1px;" tabindex="1000" title="" type="submit"> <span id="skipNav">skip to main navigation | skip to side navigation | skip to main content</span> <!-- end #skipNav --></span><!-- end #topMargin -->
<div id="headerContainer">
<div id="header">
<div id="companyLogo">
<img src="docs/pics/company_logo.png" width="103" height="17" alt="Hitachi">
<div class="line"></div>
</div>
<div id="topButtons">
<ul>
<li><input class="submit submitIcon back" name="SUBMIT-BACK.x" title="Back" type="submit" value=""></li>
<li class="inactive"><input class="submit inactiveIcon home" disabled="disabled" name="SUBMIT-HOME.x" title="Main menu (Disabled)" type="submit" value=""></li>
<li class="inactive"><input class="submit inactiveIcon refresh" disabled="disabled" name="SUBMIT-REFRESH.x" title="Refresh (Disabled)" type="submit" value=""></li>
<li><input class="submit submitIcon logout" name="SUBMIT-LOGOUT.x" title="Logout" type="submit" value=""></li>
</ul>
</div><!-- end #topButtons -->
<div id="topMenuBar">
<div class="clearFloat"></div>
</div><!-- end #topMenuBar -->
</div><!-- end #header -->
<div id="userInfo">
<img src="docs/pics/icon_idcard.png" alt="ID" width="16" height="12"> ID: username <img src="docs/pics/icon_user.png" alt="User" width="10" height="14"> Name: Person Name
</div>
</div><!-- end #headerContainer -->
<div id="contentScroll">
<table cellspacing="0" id="colWrap">
<tbody>
<tr>
<td id="menuCol">
<div id="menuContent"></div><!-- end #menuContent -->
</td><!-- end #menuCol -->
<td id="mainCol">
<div id="content">
<h1>Verify password <span class="selectedObj"></span></h1><br>
<input type="hidden" name="LANG" value="en-US"><input type="hidden" name="SKIN" value="default"> <span class="bold">Enter password:</span>
<table cellspacing="0" class="border">
<tbody>
<tr>
<td class="prompt" width="50%"><span>Enter password for AD:</span></td>
<td width="50%"><input class="password text" maxlength="250" name="_MYPW" type="password"></td>
</tr>
<tr class="foot">
<td colspan="2"><input class="submit" name="SUBMIT-VERIFY.x" type="submit" value="Verify password"></td>
</tr>
</tbody>
</table><input type="hidden" name="SETTABLEFIELDSDB" value=""> <input type="hidden" name="SETTABLEFIELDSCOOKIE" value="">
</div><!-- end #content -->
</td><!-- end #mainCol -->
</tr>
</tbody>
</table><!-- end #colWrap -->
</div><!-- end #contentScroll -->
<div id="footer">
<div id="footerCompany">
Company Name
</div>
<div id="footerVersion">
<b>Hitachi ID Identity and Access Management Suite</b> v8.2.7.60749
</div>
<div id="footerCopyright">
<div>
<sup> </sup>© 2014 <a id="footerLink" href="http://Hitachi-ID.com" rel="external" target="_blank">Hitachi ID Systems, Inc.</a>
</div>
</div>
</div>
</div><!-- end #container -->
</form>
</body>
</html>
DocumentCompleted can get fired multiple times if your page uses frames. According to the MSDN documentation the event only gets fired once in pages with no frames. In pages where multiple frames are loaded, this event fires for each frame where the DownloadBegin event has fired.
If this causes a problem you could add an event handler to onload which only get fired once:
this.webBrowser1.Document.Window.AttachEventHandler("onload", delegate
{
// Defer this to make sure all possible onload event handlers got fired
System.Threading.SynchronizationContext.Current.Post(delegate
{
// try webBrowser1.Document.GetElementById("id") here
MessageBox.Show("window.onload was fired, can access DOM!");
}, null);
});
The DocumentCompleted event will fire for each frame and link referenced in the page loaded - see this question for more info.
A better alternative would be to use the Navigated event, or check the ReadyState of the browser control.
if (browser.ReadyState != WebBrowserReadyState.Complete) {
return;
}
I( have an MVC 5 application that is also using angularjs and boot strap. When the page loads the modal doesnt launch and i get the following err in the console:
Uncaught Error: [$injector:modulerr] http://errors.angularjs.org/1.2.8/$injector/modulerr?p0=myApp&p1=Error%3A%2….c%20(http%3A%2F%2Flocalhost%3A60248%2FScripts%2Fangular.min.js%3A17%3A431)
Here is my html:
Layout:
<!DOCTYPE html>
<html ng-app ="myApp">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Temujin #ViewBag.Title</title>
<link href="~/Content/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/Site.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/modernizr-2.6.2.js"></script>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<script src="~/Scripts/angular.min.js"></script>
<script src="~/js/Login.js"></script>
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
#Html.ActionLink("Temujin", "Index", "Home", null, new { #class = "navbar-brand" })
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
</ul>
</div>
</div>
</div>
<div class="container body-content">
#RenderBody()
<hr />
<footer>
<p>© #DateTime.Now.Year - Temujin</p>
</footer>
</div>
</body>
</html>
Directive template:
<div class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
<form class="form-signin" name="authForm" ng-submit="auth()" ng-controller ="AuthController" novalidate>
<input type="text" class="form-control" placeholder="user name" ng-model ="AuthController.user.username" required autofocus>
<input type="password" class="form-control" placeholder="password" ng-model ="AuthController.user.password" required>
<input type="submit" class="btn btn-primary" value="Submit" />
</form>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
cshtml:
#{
ViewBag.Title = "Login";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2></h2>
<div id="loginBox">
<auth-modal></auth-modal>
</div>
angularjs:
(function () {
var temujin = angular.module('temujin', []);
temujin.controller('AuthModalController', ['$scope',function ($scope) {
$scope.temujin.user = {};
console.log("AuthModalController ran");
$scope.$(".modal").modal({ message: 'HEll0 World' });
}]);
temujin.directive("authModal", function () {
return { restrict: 'E', templateUrl: '\\js\\templates\\auth-modal.html', controller: 'AuthModalController',controllerAs: 'authmodalCtrl'}
});
temujin.controller('AuthController',['$scope',function ($scope) {
$scope.user = {};
console.log("AuthController ran");
$scope.auth = function () {
console.log("user " + this.user);
};
}]);
})();
MVC 5 controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace temujin.Controllers
{
public class TemujinController : Controller
{
//
// GET: /Temujin/
public ActionResult Index()
{
return View();
}
}
}
You are attempting to use the module myApp in your page here:
<html ng-app ="myApp">
But your actual module is named temujin
You just need to change your ng-app directive to point to the right module name.
<html ng-app ="temujin">