very strange problem: nothing happens after submitting in aspx webpage - asp.net

tested on: windows server 2008 with visual studio 2010 and windows vista with visual studio 2008.
following unusuall problem has appeared.
i have a usercontrol and website where control will be showed.
if im checking radio buttons of control and clicking on submit which is also in ctrol inside there happens nothing. no request to server, just silence.
everything looks fine and standard but i cant find a problem. please help, because its annoying!
usercontrol.ascx:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="EmployeeCategorizationControl.ascx.cs"
Inherits="EmployeeCategorizationControl.EmployeeCategorizationControl" %>
<div id="categorizationOfEmployee">
<div>Categorization od Employee</div><br />
<div id="firstCategory">
<div style="float: left; width: 250px;">
Is not a permanent employee</div>
<div>
<asp:RadioButtonList ID="YesNoIsNotPermanentEmployee" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:RadioButtonList>
</div>
</div>
<div id="secondCategory">
<div style="float: left; width: 250px;">
Is a fixed-term employee</div>
<div>
<asp:RadioButtonList ID="YesNoIsFixedTermEmployee" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:RadioButtonList>
</div>
</div>
<div id="thirdCategory">
<div style="float: left; width: 250px;">
No external recruit</div>
<div>
<asp:RadioButtonList ID="YesNoExternalRecruit" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Text="Yes" Value="1"></asp:ListItem>
<asp:ListItem Text="No" Value="0"></asp:ListItem>
</asp:RadioButtonList>
</div>
</div>
<div id="btCreate" style="margin-left: 200px; margin-top: 10px;">
<asp:Button runat="server" Text="Create Checklist" ID="btCreateChecklist" />
</div>
</div>
usercontrol.ascx.cs:
protected void Page_Load(object sender, EventArgs e)
{
btCreateChecklist.Click += new EventHandler(btCreateChecklist_Click);
}
void btCreateChecklist_Click(object sender, EventArgs e)
{
ValueOfIsNotPermanentEmployee = YesNoIsNotPermanentEmployee.Text;
ValueOfIsFixedTermEmployee = YesNoIsFixedTermEmployee.Text;
ValueOfNoExternalRecruit = YesNoExternalRecruit.Text;
UserCategoryID = ValueOfIsNotPermanentEmployee + ValueOfIsFixedTermEmployee + ValueOfNoExternalRecruit;
}
default.aspx:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="EmployeeCategorizationControl._Default" %>
<%# Register TagPrefix="UserControl" TagName="EmployeeCategorizationControl" Src="~/EmployeeCategorizationControl.ascx" %>
<!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">
<div>
<UserControl:EmployeeCategorizationControl runat="server" />
</div>
</form>
</body>
</html>

This code appears to work perfectly as I see it. I've transplanted your code into a local application as is (changing namespaces to eliminate compile errors) and it posts back just fine. However, your event doesn't do anything except set a couple of variables (which you don't explain what they do or relate to). Are you sure it's not performing the post back? This page is small enough that a postback may not even cause the screen to flash (since there is no actual action going on). You should put some visible action into the event method such as changing the text of a label or the BackColor of the button.

If you have AutoEventWireup="true" there is no need for:
btCreateChecklist.Click += new EventHandler(btCreateChecklist_Click);
Either set it to false or remove the above statement.

Related

Focus issue in a multistep asp.net webform with Wizard control with NVDA screen reader

I am using an ASP.NET Wizard control to display a multi steps process. I have to make the form accessible with NVDA screen reader and with all browsers. The form is accessible in Chrome as the NVDA is reading the screen from the top This is header to bottom in order. But when checking the same form in Firefox + NVDA, the focus is sometimes moving to middle and sometimes to the footer. My requirement is screen reader should always read from the This is header in all the wizard steps. Please, I need your help to solve the issue. My Code is as below:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WizardRadioButtonListDemo.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Accessibile Form</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Wizard ID="Wizard1" runat="server" DisplaySideBar="false">
<HeaderTemplate>
<h1>This is header</h1>
</HeaderTemplate>
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
<fieldset id="Fieldset1" runat="server">
<legend id="Legend1" runat="server">Type</legend>
<asp:RadioButtonList ID="rdoServiceType" RepeatLayout="Flow" runat="server">
<asp:ListItem Text="Gold" Value="0">Gold</asp:ListItem>
<asp:ListItem Text="Siver" Value="1">Silver</asp:ListItem>
<asp:ListItem Text="Premium" Value="2">Premium</asp:ListItem>
</asp:RadioButtonList>
</fieldset>
</asp:WizardStep>
<asp:WizardStep>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button ID="btnFileUpload" runat="server" Text="Upload" />
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2">
<fieldset id="Fieldset2" runat="server">
<legend id="Legend2" runat="server">User</legend>
<asp:Label ID="lblFirstName" runat="server" Text="First Name" AssociatedControlID="txtFirstName"></asp:Label>
<asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
<asp:Label ID="lblLastName" runat="server" Text="Last Name" AssociatedControlID="txtLastName"></asp:Label>
<asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
</fieldset>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
</div>
</form>
<p>© 2017 Test LLC.. All rights reserved. Powered by Test</p>
</body>
</html>
Okay so heres the issue I think. So you want the user to read the h1 by tabbing. One solution would be to add a tab-index of 0 to the header.
Why?
Because by default html, the only tabbable elements are Links, buttons, & inputs. H1's and p-tags don't do that. But they can if you give them a tab-index of 0...
So add this:
<HeaderTemplate tabindex="0">
<h1>This is header</h1>
</HeaderTemplate>
I might've interpreted your question wrong. If that's not the case, you can always add tab-index of positive values to your form in the sections you want it to go to.
Such as:tab-index="1"
... etc, and keep going up.

show an Image on Click of a LinkButton Control

How to show an image in ContentPlaceHolder4 on click of a Link Button which is placed on ContentPlaceHolder3.
I Have a Master Page and one content page. On master page i have a link INSTRUMENTS by clicking on which i am redirected to content page INSTRUMENTS. Now i have 10 LINK BUTTON controls on my Content Page and i want on the click of each link button corresponding image should open on same content page but in different CntentPlaceHolder. Please guide me how to add code for Link Button Click and how to render iamge on click of Link Button.
Following is the code i have added till now.
**This is My Master Page**
<%# Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!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>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.style1
{
}
.style2
{
width: 162px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div> <img src="IMAGES/main.png" style="background-color: #99FF99; border-top-color: #800000; width: 1082px; height: 105px;" />
</div>
HOME INSTRUMENTS LOGIN
ADDRESS
<table style="width: 100%; height: 288px; margin-top: 11px;">
<tr>
<td bgcolor="#FF0066" align="center" class="style2"
style="text-align: center; vertical-align: top;">
<asp:ContentPlaceHolder ID="ContentPlaceHolder3" runat="server">
</asp:ContentPlaceHolder>
</td>
<td bgcolor="#33CCCC" class="style1">
<asp:ContentPlaceHolder ID="ContentPlaceHolder4" runat="server">
</asp:ContentPlaceHolder>
</td>
</tr>
</table>
</form>
</body>
</html>
**This is My Content Page**
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="INSTRUMENTS.aspx.cs" Inherits="INSTRUMENTS" %>
<asp:Content id="content3" ContentPlaceHolderID="head" runat="server">
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server">
<asp:LinkButton ID="LinkButton1" runat="server" OnClick="lkbutton_click">Sitar</asp:LinkButton><br />
<asp:LinkButton ID="LinkButton2" runat="server">Harmonium</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton3" runat="server">Tabla</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton4" runat="server">Drum</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton5" runat="server">Guitar</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton6" runat="server">Sarod</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton7" runat="server">Flute</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton8" runat="server">Santoor</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton9" runat="server" onclick="LinkButton9_Click">Keyboard</asp:LinkButton>
<br />
<asp:LinkButton ID="LinkButton10" runat="server">LinkButton</asp:LinkButton>
</asp:Content>
<asp:content ID ="C2" ContentPlaceHolderID ="ContentPlaceHolder4" runat="Server">
<asp:Image ID ="I1" ImageUrl ="~/IMAGES/F.png" >
<asp:Image />
</asp:content>
in your design page use like this.
<asp:Content ContentPlaceHolderID="ContentPlaceHolder4" Runat="Server">
<img id="img1" runat="server" />
</asp:Content>
and in code behind link button click event like below:
protected void lkbutton_click(object sender, EventArgs e)
{
img1.Src = "~/images/sonata-logo.png";
}
i tested it it's working fine.
but put the correct path of image then only it will show.
Thanks
<asp:LinkButton ID="LinkButton1" runat="server" width="250px" height="250">
<img runat="server" id="IL"src="~/Class/Adds/0/4.jpg" width="250" height="250" />
</asp:LinkButton>
With this you can change the picture with server code.
il.SRC = "~/Class/Adds/0/7.jpg"

User control as Image button

I have created user control with label and image
i need raise event when click on the user control
when click on the div which contain the label and image
user control code is bellow
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="ImageButton.ascx.cs" Inherits="AdvancedGrid.UC.ImageButton" %>
<div id="divClickableDiv" runat="server">
<div>
<asp:Image ID="Button_Image" ImageUrl="" runat="server" />
</div>
<div>
<asp:Label ID="Button_Text" runat="server" Text="Button"></asp:Label>
</div>
</div>
why not use use ImageButton control instead of Image if that is what you need? Try something like this:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="ImageButton.ascx.cs" Inherits="AdvancedGrid.UC.ImageButton" %>
<div id="divClickableDiv" runat="server">
<div>
<asp:ImageButton ID="Button_Image" ImageUrl="" runat="server" OnClick="Button_Image_Click" />
</div>
<div>
<asp:Label ID="Button_Text" runat="server" Text="Button"></asp:Label>
</div>
</div>
- OnClick="Button_Image_Click" takes you to code behind where you can go to any URL you want like this:
protected void Button_Image_Click(object sender, EventArgs e)
{
Response.Redirect("~/page.aspx");
}
- or instead of OnClick and without code-behind try:
<asp:ImageButton ID="Button_Image" ImageUrl="" runat="server" OnClick="window.location.href = '<%= ResolveUrl("~/page.aspx") %>'" />
or
<asp:ImageButton ID="Button_Image" ImageUrl="" runat="server" OnClientClick="window.location.href='page.aspx'; return false;" />

How to open ajax model popup extender just like facebook image viewer?

I want to use ajax ModelpopupExtender control in my .aspx page in visual studio 2010. When user clicks any button,It should open popup like facebook opens popup to show photos. That means pop up should get opened in such a way that it should disable the background until closed button is clicked of that popup. How to open page or panel or any other thing in that popup. Please mention clear steps. I dont have even bit of idea how to do this?
Thanks in advance...
<%# Page Language="C#" AutoEventWireup="true"
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%# Register Assembly="AjaxControlToolkit"
Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!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>Ajax Model PopUp Extender With MouseOver Example</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">
function MouseHover()
{
$find("modelPopupExtender1").show();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<ajaxToolkit:ToolkitScriptManager ID="toolKitScriptManager1"
runat="server">
</ajaxToolkit:ToolkitScriptManager>
<p style="background-color: #9999FF; width: 95%;">
Example of using a ModalPopupExtender with with Mouse Over
<br/></p><br/>
Hover over the hyperlink
<asp:HyperLink ID="HyperLink1" runat="server"
onmouseover="MouseHover();"
Font-Underline="True" ForeColor="Blue">
<b>Mouse Over Here to Open PopUp</b>
</asp:HyperLink> to open pop up
<ajaxToolkit:ModalPopupExtender runat="server"
BehaviorID="modelPopupExtender1"
TargetControlID="HyperLink1"
PopupControlID="popUpPanel"
OkControlID="btnOk"
BackgroundCssClass="modalBackground" >
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="popUpPanel" runat="server"
CssClass="confirm-dialog">
<div class="inner">
<h2>
Thanks For Visiting This Site</h2>
<div class="base">
<asp:Button ID="btnOk" runat="server" Text="Ok"/>
<asp:LinkButton ID="LinkButton1" runat="server"
CssClass="close"
OnClientClick="$find('modelPopupExtender1').hide(); return false;"/>
</div></div>
</asp:Panel>
</div>
</form>
</body>
</html>
BackgroundCssClass="modalBackground" did you notice this line this is where you define the css for the background.
I think this should work.
Reference

How can I make a validation icon appear beside a asp:textbox?

Using this code, I can get a very cheesy red lettered message.
<form id="frmValidator" action="required.aspx" method="post" runat="server">
Enter Your Name:
<asp:TextBox id="txtName" runat="server" />
<asp:RequiredFieldValidator id="valTxtName" ControlToValidate="txtName" ErrorMessage="Please enter your name!" runat="server" />
<br />
<asp:button id="btnSubmit" text="Submit" runat="server" />
</form>
Is there some way for me to have a green icon (I have that image so I imagine I just have to reference it) sort of fade into existence beside the control?
Thanks a bunch. :)
You set the ErrorMessage property to a link to an image
e.g. ErrorMessage='<img src="error.gif">'
See this MSDN article.
You can do this
<%# 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>
<style type="text/css">
</style>
<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
BorderStyle="None" ControlToValidate="TextBox1" CssClass="newStyle1"></asp:RequiredFieldValidator>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
</body>
</html>
.newStyle1
{
background-image: url('Pic.png');
width: 500px;
height: 300px;
}
So basically just don't have any text for the error message and set the css property in the validation controls to have a css class.

Resources