Compiler error on asp.net page with form submit - c#

I try to firean submit via an asp button. I got the error that there is no definition vor SubmitBtn_Click in 'ASP.default_aspx.
BootstrapASP.Master:
<%# Master Language="C#" AutoEventWireup="true" CodeBehind="BootstrapASP.master.cs" Inherits="Shift.BootstrapASP" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html" charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Shift</title>
<link type="text/css" rel="stylesheet" href="css/bootstrap.css" />
<link type="text/css" rel="stylesheet" href="css/main.css" />
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
<![endif]-->
<asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder>
</head>
<body>
<div>
<asp:ContentPlaceHolder ID="ContentMain" runat="server"></asp:ContentPlaceHolder>
</div>
<script src="js/jquery-1.10.2.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/interactive.js"></script>
</body>
</html>
Default.aspx:
<%# Page Title="Shift" Language="C#" MasterPageFile="~/BootstrapASP.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Shift.WebForm1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentMain" runat="server">
<div class="container content-wrapper">
<form role="form" runat="server">
<div class="row">
<div class="col-md-4 col-md-offset-7">
<asp:LinkButton ID="SubmitBtn" runat="server" OnClick="SubmitBtn_Click" CssClass="btn btn-danger btn-lg pull-right">
<span class="glyphicon glyphicon-import"></span> Senden
</asp:LinkButton>
</div>
</div>
<div class="row">
<div class="col-md-4 col-md-offset-1">
<h1>Set Down</h1>
<hr />
<div id="down-form-holder">
<div class="form-group">
<label for="old-pc-ci">Computer CI*</label>
<input type="text" class="form-control" name="old-pc-ci" id="old-pc-ci" />
</div>
<div class="form-group">
<label for="old-mon-ci">Monitor CI*</label>
<input type="text" class="form-control" name="old-mon-ci[]" id="old-mon-ci" />
</div>
</div>
<button type="button" id="old-add-monitor" class="btn btn-default btn-sm pull-right">
<span class="glyphicon glyphicon-plus"></span> Monitor
</button>
</div>
</div>
</form>
</div>
</asp:Content>
In the Default.aspx.cs I created an eventhandler for the "SubmitBtn_Click"
Default.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Shift
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
void SubmitBtn_Click(Object sender, EventArgs e)
{
}
}
}

Methods in C# are private by default, so your click handler is not visible from the markup. Common practice is to make them protected:
protected void SubmitBtn_Click(Object sender, EventArgs e)

Your event needs to be protected, the way you have it is defaulting to private:
protected void SubmitBtn_Click(Object sender, EventArgs e)
{
}

protected void SubmitBtn_Click(object sender, EventArgs e)
{
}
<asp:LinkButton ID="SubmitBtn" runat="server" OnClick="SubmitBtn_Click" CssClass="btn
btn-danger btn-lg pull-right">
<span class="glyphicon glyphicon-import"></span> Senden</asp:LinkButton>

Related

WebBrowser.DocumentComplete fires multiple times per request? [duplicate]

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;
}

Uncaught Error when loading page

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">

how to code behind a html button?

I am trying to redirect to Search.aspx after login button is clicked. the login button is a html5 button. I googled and they say to make it work is to add the runat="server" and önserverclick="Button1_Click". After I done that, I double click on the login button on design mode. and it generates
function Button1_onclick() {
}
I put the Response.Redirect("Search.aspx"); inside the function. And it still have no effect when I click the Login button.
SOURCE CODE
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
</style>
<link rel="stylesheet" type="text/css" href="stylesheets/loginstyle.css" />
<script language="javascript" type="text/javascript">
// <![CDATA[
function Button1_onclick() {
Response.Redirect("Search.aspx");
}
// ]]>
</script>
</head>
<body>
<div id="wrapper">
<form name="login-form" class="login-form" action="" method="post">
<div class="header">
<h1>Login Form</h1>
<span>Fill out the form below to login to my super awesome imaginary control panel.</span>
</div>
<div class="content">
<input name="username" type="text" class="input username" placeholder="Username" />
<div class="user-icon"></div>
<input name="password" type="password" class="input password" placeholder="Password" />
<div class="pass-icon"></div>
</div>
<div class="footer">
<input type="button" name="submit" value="Login" class="button" runat="server" id="Button1" önserverclick="Button1_Click" onclick="return Button1_onclick()" />
</div>
</form>
</div>
<div class="gradient"></div>
</body>
</html>
CODE BEHIND CODE(NOCODE)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Login : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
try below code I hope it would help!!
function Button1_onclick()
{
window.location.assign("Search.aspx")
}

Problems in DropDownList with updatepanel

I have two DropDownList with update panel when i select value from first dropdownlist then in second dropdownlist display data related first. But there is problem at run time it can't display dropdownlist and continuously refresh this page.
So please help to solve this problem.
Here is my code ASPX PAGE
<%# Page Language="C#" AutoEventWireup="true" CodeFile="AddRoomPrice.aspx.cs" Inherits="AddRoomPrice" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Presha Admin</title>
<style type="text/css">
#import url("css/style.css");
#import url('css/style_text.css');
#import url('css/form-buttons.css');
#import url('css/link-buttons.css');
#import url('css/menu.css');
#import url('css/statics.css');
#import url('css/messages.css');
#import url('css/table-sorter.css');
#import url('css/tabs.css');
#import url('css/forms.css');
#import url('css/datepicker.css');
#import url('css/jquery.fancybox-1.3.4.css');
#import url('css/accordions.css');
#import url('css/jquery.treeview.css');
#import url('css/wysiwyg.css');
#import url('css/wysiwyg.modal.css');
#import url('css/wysiwyg-editor.css');
</style>
<script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>
<link rel="shortcut icon" href="gfx/Favicon.png">
<link rel="stylesheet" type="text/css" href="css/component.css" />
<script type="text/javascript" src="js/modernizr.custom.js"></script>
<!--[if lte IE 8]>
<script type="text/javascript" src="js/excanvas.min.js"></script>
<![endif]-->
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div class="container">
<div class="logo-labels">
<img id="logo" runat="server" src="~/gfx/logo.png" height="50" />
<ul>
<li><asp:Label ID="lblAdmin" runat="server" Text="Wel come "></asp:Label></li>
<li class="logout"><asp:LinkButton ID="lnkLogout" runat="server" onclick="lnkLogout_Click"><span>Logout</span></asp:LinkButton></li>
</ul>
</div>
<div class="menu-search">
<ul>
<li>Home</li>
<li>Hotel
<ul>
<li>Hotel List</li>
<li>Add Hotel</li>
</ul>
</li>
<li>Hotel Album
<ul>
<li>Album List</li>
<li>Add Album</li>
</ul>
</li>
<li>Hotel Facility
<ul>
<li>Facility List</li>
<li>Add Facility</li>
</ul>
</li>
<li>Category
<ul>
<li>Category List</li>
<li>Add Category</li>
</ul>
</li>
<li class="current">Room Price
<ul>
<li>Price List</li>
<li>Add Price</li>
</ul>
</li>
<li>New Facility</li>
<li>Admin
<ul>
<li>Admin List</li>
<li>Add Admin</li>
</ul>
</li>
<li>Inquiry</li>
<li>Map</li>
</ul>
</div>
<div class="breadcrumbs">
<ul>
<li class="home"></li>
<li class="break">»</li>
<li>Add Room Price</li>
</ul>
</div>
<div class="section">
<div class="box">
<div class="title">
<h2>Add/Edit Room Category</h2>
</div>
<div class="content forms">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="line padding-left50">
<label>Hotel</label>
<asp:DropDownList ID="ddlHotel" runat="server" AutoPostBack="true"
onselectedindexchanged="ddlHotel_SelectedIndexChanged">
</asp:DropDownList>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlHotel" EventName="selectedindexchanged" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<div class="line padding-left50">
<label>Room Category</label>
<asp:DropDownList ID="ddlCategory" runat="server">
</asp:DropDownList>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlHotel" EventName="selectedindexchanged" />
</Triggers>
</asp:UpdatePanel>
<div class="line padding-left50">
<label>Single Price</label>
<asp:TextBox ID="txtSingle" runat="server" class="medium"></asp:TextBox>
</div>
<div class="line padding-left50">
<label>Double Price</label>
<asp:TextBox ID="txtDouble" runat="server" class="medium"></asp:TextBox>
</div>
<div class="line padding-left50">
<label>Extra Bed Price</label>
<asp:TextBox ID="txtExtraBed" runat="server" class="medium"></asp:TextBox>
</div>
<div class="line padding-left50">
<label>Meal Plan</label>
<asp:TextBox ID="txtMealPlan" runat="server" class="medium"></asp:TextBox>
</div>
<div class="line padding-left50">
<label>Extra Meal Price</label>
<asp:TextBox ID="txtExtraMeal" runat="server" class="medium"></asp:TextBox>
</div>
<div class="line button" style="padding-left:325px">
<asp:Button ID="btnSubmit" runat="server" Text="Sumbit" CssClass="btn btn-2 btn-2d" onclick="btnSubmit_Click"></asp:Button>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/superfish.js"></script>
<script type="text/javascript" src="js/supersubs.js"></script>
<script type="text/javascript" src="js/hoverIntent.js"></script>
<script type="text/javascript" src="js/jquery.flot.js"></script>
<script type="text/javascript" src="js/jquery.graphtable-0.2.js"></script>
<script type="text/javascript" src="js/jquery-ui.js"></script>
<script type="text/javascript" src="js/customInput.jquery.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.js"></script>
<script type="text/javascript" src="js/jquery.tablesorter.pager.js"></script>
<script type="text/javascript" src="js/jquery.sparkbox-select.js"></script>
<script type="text/javascript" src="js/jquery.fancybox-1.3.4.js"></script>
<script type="text/javascript" src="js/jquery.filestyle.mini.js"></script>
<script type="text/javascript" src="js/date.js"></script>
<script type="text/javascript" src="js/jquery.datepicker.js"></script>
<script type="text/javascript" src="js/jquery.treeview.js"></script>
<script type="text/javascript" src="js/jquery.tipsy.js"></script>
<script type="text/javascript" src="js/jquery.wysiwyg.js"></script>
<script type="text/javascript" src="js/plugins/wysiwyg.rmFormat.js"></script>
<script type="text/javascript" src="js/controls/wysiwyg.image.js"></script>
<script type="text/javascript" src="js/controls/wysiwyg.link.js"></script>
<script type="text/javascript" src="js/controls/wysiwyg.table.js"></script>
<script type="text/javascript" src="js/inline.js"></script>
</form>
</body>
</html>
and here is CS code
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using BLL;
public partial class AddRoomPrice : System.Web.UI.Page
{
clsbll bll = new clsbll();
protected void Page_Load(object sender, EventArgs e)
{
if (Session["admin"] != null)
{
lblAdmin.Text = "Wel Come " + Session["admin"].ToString();
}
else
{
Response.Redirect("Login.aspx");
}
if (!Page.IsPostBack)
{
if (Session["hotelID"] != null)
{
ddlHotel.SelectedValue = Session["hotelID"].ToString();
}
ddlHotel.DataSource = bll.getHotel();
ddlHotel.DataTextField = "HName";
ddlHotel.DataValueField = "HotelID";
ddlHotel.DataBind();
ddlHotel.Items.Insert(0, "Select Hotel");
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
bll.insertRoomPrice(txtSingle.Text, txtDouble.Text, txtExtraBed.Text, txtMealPlan.Text, txtExtraMeal.Text, Convert.ToInt32(ddlCategory.SelectedValue), Convert.ToInt32(ddlHotel.SelectedValue));
txtSingle.Text = "";
txtDouble.Text = "";
txtExtraBed.Text = "";
txtMealPlan.Text = "";
txtExtraMeal.Text = "";
ddlCategory.SelectedIndex = 0;
ddlHotel.SelectedIndex = 0;
Session.Remove("hotelID");
//Session.Remove("hotel");
}
protected void ddlHotel_SelectedIndexChanged(object sender, EventArgs e)
{
ddlCategory.DataSource = bll.getCategoryByID(ddlHotel.SelectedValue);
ddlCategory.DataTextField = "RCategoryNameBed";
ddlCategory.DataValueField = "RCategoryID";
ddlCategory.DataBind();
ddlCategory.Items.Insert(0, "Select Category");
}
protected void lnkLogout_Click(object sender, EventArgs e)
{
Session.Remove("admin");
Response.Redirect("Login.aspx");
}
}
So please reply as soon as possible
Thanks
It is not you calling the page load function, that is the way ASP.NET works. The page posts to itself, thus calling the page_load function, when any Server controls on the page are fired (those which as set to postback).
What you need to do is to put some checks to differentiate between an initial page load and a post back
if(!IsPostBack)
{
//Code when initial loading
}
else
{
// code when post back
}
UpdatePanel control has been designed to refresh only its content.
For filtering purpose you can choose one of these methods:
All related DropDownLists must be placed inside one UpdatePanel.
or
First UpdatePanel and its content must be nested in second UpdatePanel.(Not Recommended)
There is no need to declare AsyncPostBackTrigger in both methods.
Good luck.
Maybe following code resolve the problem:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["admin"] == null)
Response.Redirect("Login.aspx");
else
{
lblAdmin.Text = "Welcome " + Session["admin"].ToString();
ddlHotel.Items.Clear();
ddlHotel.Items.Add(new ListItem("Select Hotel", ""));
ddlHotel.AppendDataBoundItems = true;
ddlHotel.DataSource = bll.getHotel();
ddlHotel.DataTextField = "HName";
ddlHotel.DataValueField = "HotelID";
ddlHotel.DataBind();
if (Session["hotelID"] == null)
ddlHotel.SelectedIndex = 0;
else
ddlHotel.SelectedValue = Session["hotelID"].ToString();
ddlHotel_SelectedIndexChanged(null,null);
}
}
}
protected void ddlHotel_SelectedIndexChanged(object sender, EventArgs e)
{
ddlCategory.Items.Clear();
ddlCategory.Items.Add(new ListItem("Select Category", ""));
ddlCategory.AppendDataBoundItems = true;
ddlCategory.DataSource = bll.getCategoryByID(ddlHotel.SelectedValue);
ddlCategory.DataTextField = "RCategoryNameBed";
ddlCategory.DataValueField = "RCategoryID";
ddlCategory.DataBind();
}
if not, I am so sorry, I can not help you more.

View Navigation using buttons in MVC

I am trying to create a View with 2 buttons that redirect users to other views but nothing happens when they are clicked. What am I doing wrong? Thanks in advance.
<% using (Html.BeginForm()) {%>
<p>
Please LogIn or Register
</p>
<p>
<button name="button" type="button"onclick="document.location.href=$('#logInUrl').attr('href')">LogIn</button>
<button name="button" type="button" onclick="document.location.href=$('#createAccountUrl').attr('href')">Register</button>
<a id="logInUrl" href="<%= Html.AttributeEncode(Url.Action("Account", "LogOn")) %>" style="display:none;"></a>
<a id="createAccountUrl" href="<%= Html.AttributeEncode(Url.Action("Account", "Register")) %>" style="display:none;"></a>
</p>
<% } %>
Working Code
<asp:Content ID="Main" ContentPlaceHolderID="MainContent" runat="server">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" language="javascript" type="text/javascript"></script>
<script language="JavaScript" type="text/javascript">
$(document).ready(function()
{
$('#button1').click(function ()
{
document.location.href = $('#logInUrl').attr('href');
});
$('#button2').click(function ()
{
document.location.href = $('#createAccountUrl').attr('href');
});
});
</script>
<% using (Html.BeginForm()) {%>
<p>
Please LogIn or Register
</p>
<p>
<button name="button1" type="button" id="button1">LogIn</button>
<button name="button2" type="button" id="button2">Register</button>
<a id="logInUrl" href="<%= Html.AttributeEncode(Url.Action("LogOn", "Account")) %>" style="display:none;"></a>
<a id="createAccountUrl" href="<%= Html.AttributeEncode(Url.Action("Register", "Account")) %>" style="display:none;"></a>
</p>
<% } %>
</asp:Content>
Since it looks like you are using jquery, don't use onclick on the button but jquery click function of the buttons like
$('#button1').click(function() {
document.location.href=$('#logInUrl').attr('href');
});
$('#button2').click(function() {
document.location.href=$('#createAccountUrl').attr('href');
});
<button name="button" type="button" id="button1">LogIn</button>
<button name="button" type="button" id="button2">Register</button>

Categories