ASP.NET Website - .cs file cannot read the labels from .aspx file - c#

I appreciate this is a common occurrence, however I've tried some of the solutions and none of worked thus far. My project is a 'Web Site' within Visual Studio, thus I don't have the option to 'Right Click and Crete new application'.
The labelID names from my aspx file cannot be read in the corresponding .cs file - flags up with syntax errors.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="txtCity" runat="server" Text="" />
<asp:Button Text="Get Weather Forecast" runat="server" OnClick="GetWeatherInfo" Width="207px" />
<hr />
<asp:Repeater ID="Repeater_weatherReports" runat="server">
<ItemTemplate>
<table id="tblWeather" runat="server" border="0" visible="false">
<tr>
<th>
Weather Info
</th>
</tr>
<tr>
<td>
<asp:Label runat="server" ID="lblCity_Country" Text='<%# Eval("city.name") %>' />
humidity:<asp:Label runat="server" ID="Label_humidity" Text='<%# Eval("main.humidity") %>' />
</td>
</tr>
<tr>
<td>
min:<asp:Label runat="server" ID="Label_min" Text='<%# Eval("main.temp_min") %>' />
max:<asp:Label runat="server" ID="Label_max" Text='<%# Eval("main.temp_max") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
</form>
</body>
</html>
A strange thing is, I can't even see the labelIDs if I click on the 'Design' view. See screenshot. Am I supposed to see the labelIDs here?
Any help will be much appreciated, Thanks
Edit - heres my c# code. Must I loop over RepeatItems somehow?
WeatherInfo weatherinfo = serializer.Deserialize<WeatherInfo>(json);
Repeater_weatherReports.DataSource = weatherinfo.list;
Repeater_weatherReports.DataBind();
int i = 0;
foreach (List list in weatherinfo.list)
{
lblCity_Country = weatherinfo.city.name;
//lblDescription.Text = weatherinfo.list[0].weather[0].description;
Label_min = string.Format("{0}", Math.Round(weatherinfo.list[i].main.temp_min, 1));
Label_max = string.Format("{0}", Math.Round(weatherinfo.list[i].main.temp_max, 1));
Label_humidity = weatherinfo.list[i].main.humidity.ToString();
tblWeather.Visible = true;
i++;
}

You can not access direct to label that is inside of repeater or gridview or other data binding controls. You can use events of repeater to access them. e.x:
<asp:repeater onitemcreated="methodnameToCall1" onitemdatabind="methodnameToCall2" >
and find labels by findcontrol method in c#:
void methodnameToCall1(object s,typeofitemcreatedEventsArgs e){
if(e.itemtype == dataitemtype){
var lbl = e.item.findcontrol("lblId") as Label;
}
}
It is semi code, because wrote in stack android app!
Excuseme!

For starters, you can mark table visible="true". Then, you will be able to see the repeater atleast in design view.
protected void Repeater_weatherReports_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if (item.ItemType == ListItemType.AlternatingItem || item.ItemType == ListItemType.Item)
{
Label lblmin = (Label)item.FindControl("Label_min");
Label lblmax = (Label)item.FindControl("Label_max");
//.........and you can set of get values here.
}
}
In your aspx page, in the line where asp:Repeater is defined, you can add
OnItemDataBound="Repeater_weatherReports_ItemDataBound", it will start working.

Related

Dynamically Create a specific div with its children in C#

I'm sorry in advance if this seems to be a beginners question and wasted some of your time, but it does really bother me and I would really appreciate it if someone could help.
I'm simply creating a "zone" if you will, where the user inputs a word/sentence which are tasks, and then can check if the task was completed or not and/or if the word/sentence needs to be changed.
So in the end, what I need is a textbox lets say where the user inputs a specific number supposed x, and generates x times this div.
Here is the code (unfortunately I could not post pics since I do not have enough reputation..)
ASP.NET code
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="GMode.tiz.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>whatevz</title>
<link href="StyleSheet1.css" rel="stylesheet" />
<script src="../jquery-1.11.3.min.js"></script>
<script src="../functions.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div class="singleContainer">
<div class="lblPlace">
<asp:Label ID="lbl" runat="server" Text="Input Task"></asp:Label>
<asp:TextBox ID="hi" CssClass="txtBox" runat="server"></asp:TextBox>
</div>
<asp:Button ID="save" runat="server" CssClass="UniversalBtn" OnClick="btnCheck_Click" />
<asp:Button ID="cancel" runat="server" CssClass="UniversalBtn" OnClick="btnCancel_Click" />
<asp:Button ID="edit" runat="server" CssClass="UniversalBtn" />
<asp:Button ID="submit" runat="server" CssClass="BtnSubmit" OnClick="btnSubmit_Click" Text="DONE"/>
</div>
</form>
</body>
</html>
C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace GMode.tiz
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnCheck_Click(object sender, EventArgs e)
{
lbl.CssClass = "done";
}
protected void btnCancel_Click(object sender, EventArgs e)
{
lbl.CssClass = "undone";
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (hi.Text == "")
{
lbl.Text = "No Value";
}
else
{
lbl.Text = hi.Text;
}
}
}
}
So basically I want to dynamically create <div class="singleContainer"> with everything inside it x times (x defined by the user).
I'm going about this more on the fact like it's C++. When you can dynamically create an array with a specific number x.
Please tell me if you need more of the code. There are still the css and js files that I did not post.
Thank you,
Jack
I think that for this the best option is to use AngularJS, you can do something like this:
<html>
<head>
<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-resource.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular-route.min.js"></script>
<script>
var app = angular.module('app', [])
app.controller('PostsCtrl', function ($scope) {
$scope.change = function (){
$scope.listDivs = [];
for(var i=0;i<$scope.createDiv;i++) {
$scope.listDivs.push(i);
}
}
})
</script>
</head>
<body ng-app='app'>
<div ng-controller='PostsCtrl' class='container'>
<input ng-model='createDiv' ng-change="change()"/>
<ul class='list-group'>
<li ng-repeat="post in listDivs" class='list-group-item'>
<div class="singleContainer">
<div class="lblPlace">
<asp:Label ID="lbl" runat="server" Text="Input Task"> </asp:Label>
<asp:TextBox ID="hi" CssClass="txtBox" runat="server"> </asp:TextBox>
</div>
<asp:Button ID="save" runat="server" CssClass="UniversalBtn" OnClick="btnCheck_Click" />
<asp:Button ID="cancel" runat="server" CssClass="UniversalBtn" OnClick="btnCancel_Click" />
<asp:Button ID="edit" runat="server" CssClass="UniversalBtn" />
<asp:Button ID="submit" runat="server" CssClass="BtnSubmit" OnClick="btnSubmit_Click" Text="DONE"/>
</div>
</li>
</ul>
</div>
</body>
</html>
Put your div into a usercontrol (ascx file).
In your main page add a placeholder:
<asp:PlaceHolder runat="server" ID="PlaceHolder1" />
in code behind you can add your control as often as you want:
yourControl= LoadControl("~/Controls/yourControl.ascx");
PlaceHolder1.Controls.Add(yourControl);

asp.net how render html input radio to postback

I'm using the code below to create radio buttons dynamically to a webpage as each set of data is retrieved from a database by iteration. It works well. The only problem is I need these to PostBack so further data can be retrieved depending on which radio button is clicked. I tried doing this with RadioButton controls but these wouldn't position inside of a table cell like the <span> technique does and they wouldn't create through a <span>.
int count = 0;
if (dataReader.HasRows)
{
testLabel1.Text = "dataReader.HasRows: " + dataReader.HasRows;
while (dataReader.Read())
{
count += 1;
htmlString.Append("<table border = '1'>");
htmlString.Append("<tr>");
htmlString.Append("<td>");
htmlString.Append(dataReader["dateTime"] + "<br />" + "<span><input type='radio' id='rd1'/>SOMTEXT </span>" + dataReader["statistics"]");
htmlString.Append("</td>");
htmlString.Append("</tr>");
htmlString.Append("</table>");
htmlString.Append("<br />");
}
test_populatePlaceHolder.Controls.Add(new Literal { Text = htmlString.ToString() });
dataReader.Close();
dataReader.Dispose();
}
}
}
}
I tried adding runat="server" in <span><input type='radio' id='rd1'runat='server'/>SOMTEXT </span> but it didn't create the radio button. Thanks in advance.
Don't know, how to format code in comment. One more again - if you write runat="Server" in your hand-made html, it does nothing, because this code will not be compiled, you just write html answer manually. On the other hand compilation of declarative language (asp.net, razor or any other) makes javascript, you can do it manually too, but B.Gates kindly agreed to do it for you :-)
Asp.Net design
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<!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>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server" >
<HeaderTemplate>
<table border ="1">
</HeaderTemplate>
<ItemTemplate>
<tr>
<td style="width:200px">
<asp:Label runat="server" ID="Label1"
/>
</td>
<td style="width:200px" >
<asp:RadioButton ID="RadioButton1" runat="server" Checked="false" Text = '<%# Eval("Text") %>' AutoPostBack ="true" />
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</div>
</form>
</body>
</html>
C# CodeBehind
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int num = 10;
if (Page.IsPostBack)
{
for (int i = 1; i < this.Repeater1.Controls.Count-1; i++)
{
RadioButton r = (RadioButton)this.Repeater1.Controls[i].Controls[3];
if (r.Checked)
{
num=int.Parse(r.Text.Substring(0, r.Text.IndexOf(' ')));
break;
}
}
}
this.Repeater1.DataSource = GetAll(num);
this.Repeater1.DataBind();
}
DataTable GetAll(int count)
{
Random r = new Random();
DataTable dt = new DataTable();
dt.Columns.Add("Text", typeof(string));
DateTime bs = DateTime.Now;
for (int i = 0; i < count; i++)
{
int value = r.Next(3, 10);
dt.Rows.Add(value.ToString() + " rows will be shown");
}
return dt;
}
}
Method GetAll() returns table, having count lines. In each line is text "%i rows will be shown" with random number. Table is bind to data repeater on page load event. If it is postback, number of rows is parsed from text of radiobutton inside repeater row (you can't get it from data table, it is another page, data table is already in GC)

ASP.Net UserControl click event causes only postback, and doesn't fire event

When I attached My UserControl(contains Literal control, imageButton Control, labels, click event with imageButton control)
on the main page(default.aspx) dynamically,
Each ImageButton click Event of Usercontrol doesn't firing,
only refreshed.
Moreover, Breaking Point that I settled on the first line of click event logic of ImageButton
Doesn't work.
It seems doesn't pass its click event.
Please Help me
Below is UserControl's back code
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="ContentHolder.ascx.cs" Inherits="TISSWeb.ContentHolder" %>
<asp:Panel ID="Panel2" runat="server" BorderColor="#3399FF" BorderStyle="Solid"
BorderWidth="1px" width="100%">
<asp:ImageButton ID="ImageButton1" runat="server" Width="16px"
onclick="ImageButton1_Click" />
<asp:ImageButton ID="ImageButton2" runat="server" onclick="ImageButton2_Click" Width="16px"/>
<asp:Label ID="Label1" runat="server" Text="Title"></asp:Label>
<asp:ImageButton ID="ImageButton4" runat="server" ImageUrl="~/Images/linknew.gif" />
<asp:Label ID="Label2" runat="server" Text="Date"></asp:Label>
<br />
<asp:Panel ID="Panel3" runat="server" style="overflow:hidden;height:60px;">
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</asp:Panel>
</asp:Panel>
//below is C#(asp.net) Code
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
//below if is where I settled the Break Point
if (starred == "1")
{
starred = "0";
ImageButton2.ImageUrl = "~/Images/star-off.png";
String sql = "some sql";
mysql.ExecuteNonQuery(sql);
}
else
{
starred = "1";
ImageButton2.ImageUrl = "~/Images/star-on.png";
String sql = "some sql";
mysql.ExecuteNonQuery(sql);
}
}
//Below is Main page's back code
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebForm1" %>
<%# Register src="ContentHolder.ascx" tagname="ContentHolder" tagprefix="ContentHolder" %>
<!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>
</head>
<body>
<form id="form1" runat="server">
<asp:Panel ID="Panel1" runat="server" BackColor="#006699" Height="35px"
<asp:Label ID="Label1" runat="server" Text="Subscription"></asp:Label>
</asp:Panel>
</form>
</body>
</html>
//below is C#(ASP.net) Code of main page
protected void Page_Load(object sender, EventArgs e)
{
DataTable SrcData = mysql.executeSelect("Some SQL");
for (int i = 0; i < dt.Rows.Count; i++)
{
ContentHolder uc = (ContentHolder)LoadControl("ContentHolder.ascx");
form1.Controls.Add(uc);
}
}
ok so i have tested your code ( with miner exception that you get there )
it works ( i removed all the images except ImageButton2 ) for debugging and it works.
so i would suggest that you do the same remove all images and stay with one, test it my guess
it will work, then add one other img and test, i can tell your very new to asp.net because you are using the design view to shape your page and that's why u get a lot of none breakabl space in your code
i would really recommend to not work like this because you will never learn to code HTML properly like this, take your time dont skip steps read about HTML CSS JS to better understand
when client tech is better then server and vice versa, but thats my 50 cents :)
any way enjoy.

C# ASP.NET document.getElementById not getting elments

I have done searches for this but could not find an answer that worked.
I am trying to access the asp:TextBox ID="wordList" node details and its keep return count = 0. I have tried two alternate methods as can be seen below in the javascript and do not understand why its not working. Can anyone see the reason?
Many Thanks
Jaie
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Week3.WebForm1" Theme="Theme1"%>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Grid Details</title>
</head>
<body>
<script lang="javascript" type="text/javascript" >
function ValidateWordList() {
var x = document.getElementById("wordList").innerHTML;
x += "Length" + x.length;
alert(x);
var z = document.getElementById('<%= wordList.ClientID %>').innerHTML;
alert(z);
return false;
}
</script>
<form id="form1" runat="server">
<div class="form1Box">
<br />
<asp:Label ID="lblWord" runat="server" Text="Word(s) of Puzzle:"><asp:TextBox ID="wordList" runat="server" ClientIDMode="Static"/></asp:Label>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorWordList" ControlToValidate="wordList"
CssClass="Validation" runat="server" Text="(Required)" />
<asp:RegularExpressionValidator ID="RegularExpressionValidatorWordList" ControlToValidate="wordList" runat="server" CssClass="Validation"
ValidationExpression="(^[a-zA-Z ,]*$)" ErrorMessage="(The word(s) can only be letters, space or comma's!)"/>
<asp:Button ID="btnSubmit" OnClick="btnSubmit_Click" Text="Generate Puzzle" runat="server" OnClientClick="return ValidateWordList()"/>
</div>
</form>
</body>
</html>
Are you trying to retrieve whatever value user has entered in the textbox? If so, you are probably looking for:
var x = document.getElementById("wordList").value;
Text fields do not define any inner markup, and their property innerHtml in most cases is just an empty string.

ASP.NET C# Button OnClick even not firing

I've absolutely exhausted Google and I can't find a solution to this problem. When click a button on my .aspx page, the corresponding function is not called from .aspx.cs file. I'll just post my code and see if there are any takers.
AddUser.aspx:
<%# Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="AddUser.aspx.cs" Inherits="AddUser" %>
<asp:Content ID="tb_AddUserHeader" ContentPlaceHolderID="tb_HeaderPlaceHolder" Runat="Server">
</asp:Content>
<asp:Content ID="tb_AddUserContent" ContentPlaceHolderID="tb_ContentPlaceHolder" Runat="Server">
<h1>Add User</h1>
<fieldset>
<asp:Label ID="tb_lblAddUser_Authorized" runat="server" Visible="false">
<br />
<table>
<tr>
<td><u>Username:</u></td>
<td><asp:TextBox ID="tb_txtbxUsername" runat="server" Width="200"></asp:TextBox></td>
</tr>
<tr>
<td><u>Password:</u></td>
<td><asp:TextBox ID="tb_txtbxPassword" runat="server" Width="200" TextMode="Password"></asp:TextBox></td>
</tr>
<tr>
<td><u>Account Type:</u></td>
<td><asp:DropDownList ID="tb_ddAccountType" runat="server">
<asp:ListItem Value="v" Text="Viewer"></asp:ListItem>
<asp:ListItem Value="t" Text="Tester"></asp:ListItem>
<asp:ListItem Value="a" Text="Admin"></asp:ListItem>
</asp:DropDownList></td>
</tr>
<tr>
<td><asp:Button ID="tb_btnAddUserSubmit" runat="server" Text="Submit" OnClick="tb_btnAddUserSubmit_Click" UseSubmitBehavior="true" /></td>
</tr>
</table>
<br />
</asp:Label>
<asp:Label ID="tb_lblAddUser_Output" runat="server" Visible="false"></asp:Label>
<asp:Label ID="tb_lblAddUser_Unauthorized" runat="server" Visible="true">
<br />Only administrators are authorized to view this page
<br />
<br />
</asp:Label>
</fieldset>
</asp:Content>
and my corresponding codebehind file, AddUser.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using tbBusinessObjects;
using tbWebClientControllers;
public partial class AddUser : System.Web.UI.Page
{
tbWebUserController m_userController;
protected void Page_Load(object sender, EventArgs e)
{
m_userController = new tbWebUserController();
//if (this.IsPostBack)
//{
// String username = tb_txtbxUsername.Text;
// //tb_btnAddUser_Click(sender, e);
//}
//else
{
if (HttpContext.Current.User.Identity.IsAuthenticated)
{
FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
if (ticket.UserData == "a")
{
tb_lblAddUser_Authorized.Visible = true;
tb_lblAddUser_Unauthorized.Visible = false;
}
}
}
}
protected void tb_btnAddUserSubmit_Click(object sender, EventArgs e)
{
tbUser user = new tbUser();
user.m_username = tb_txtbxUsername.Text;
user.m_password = tb_txtbxPassword.Text;
user.m_type = tb_ddAccountType.SelectedValue.ToCharArray()[0];
if (m_userController.InsertUser(user))
{
tb_lblAddUser_Output.Text = "<br />User was successfully added<br /><br />";
}
else
{
tb_lblAddUser_Output.Text = "<br />There was an error adding user<br /><br />";
}
tb_lblAddUser_Output.Visible = true;
tb_lblAddUser_Authorized.Visible = false;
}
}
I've set multiple breakpoints in my Click function and they're never hit. I tried simply catching my Page_Load function with a Page.IsPostBack, but it none of the data is saved from the textboxes or dropdown.
I've also tried changing the UseSubmitBehavior tag between true and false and removing it completely and it still doesn't work. I've copy/pasted as much code from other pages that use button events that are working and it still won't work. I have absolutely no idea what is going on right now. >_<
EDIT: And just in case it would help in any way, here is my Site.master...
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Site.master.cs" Inherits="SiteMaster" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head id="tb_head" runat="server">
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<title>KersTech Hydraulic/Electric Hybrid Data Recording and Telemetry</title>
<link href="tb_style.css" rel="stylesheet" type="text/css" media="screen" />
<asp:ContentPlaceHolder id="tb_HeaderPlaceHolder" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="tb_formBody" runat="server">
<!-- Begin wrapper -->
<div id="tb_wrapper">
<asp:Label ID="tb_lblFormsAuthenticationUserData" runat="server" Text="Nothing" Visible="false"></asp:Label>
<!-- Begin top -->
<div id="tb_top">
<ul id="tb_nav">
<asp:Label ID="tb_lblMasterMenu" runat="server"></asp:Label>
<li><asp:LoginStatus ID="tb_LoginStatus" runat="server" LogoutAction="Redirect" LogoutPageUrl="Logout.aspx" /></li>
</ul>
<div id="tb_Greeting">
<asp:LoginView ID="tb_MasterLoginView" runat="server">
<LoggedInTemplate>
Logged in as <asp:LoginName ID="MasterLoginName" runat="server" />
</LoggedInTemplate>
</asp:LoginView>
</div>
<asp:Label ID="test" runat="server"></asp:Label>
</div>
<!-- Begin content -->
<div id="tb_content">
<asp:ContentPlaceHolder id="tb_ContentPlaceHolder" runat="server">
</asp:ContentPlaceHolder>
</div>
<!-- End content -->
<!-- Begin footer -->
<div id="tb_footer"><div id="something">
<!-- Begin badges -->
<div>
<img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Strict" height="31" width="88" /> <!-- HTML validation badge -->
<a href="http://jigsaw.w3.org/css-validator/check/referer">
<img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /> <!-- CSS validation badge -->
</a>
</div></div>
<!-- End badges -->
</div>
<!-- End footer -->
</div>
<!-- End wrapper -->
</form>
</body>
</html>
EDIT2: I moved my Button outside of my label and manually set the button's visibility along with the label's visibility (that was the only reason I was using those labels in the first place), and it worked just fine. I just spent the last hour and a half trying to figure this out, so in case anyone else ever has the same issue again:
ASP:BUTTONs WILL NOT FIRE FROM INSIDE OF ASP:LABELs!!!!!
try butting this line in the page load
tb_btnAddUserSubmit.Click += new EventHandler(tb_btnAddUserSubmit_Click);
I think the problem may be that the click handler is not register in the click event
Have you copied this method from other page/application ? if yes then it will not work, So you need to delete the event and event name assigned to the button then go to design and go to button event properties go to onClick event double click next to it, it will generate event and it automatically assigns event name to the button. this should work
Try AutoEventWireup="false" in your page headers. I haven't worked in ASP.net in like 5 years but I remember that would sometimes break stuff.
I cannot find your tb_btnAddUserSubmit declaration in .cs code behind, and the handler.
You need to have a AddUser.Designer.cs class. Make sure to check that.
You also need to register the event in OnInit, instead of Page_load.

Categories