Button not firing onClick below Panel controls in IE - c#

I have a button which is not working when placed below two panels. If I move it above the panels, it works.
It works either way in Firefox. It does not work in IE 8
The button runs this code
protected void Button2_Click(object sender, EventArgs e)
{
panelForm.Enabled = true; //input panel
panelOutput.Visible = false; //output panel
Button1.Visible = true; //input panel button
}
I have some workarounds, but was hoping to find the cause of the issue.
edit: here is the markup of the second panel and button. I've tried moving the button outside of the panel and get the same result.
<asp:Content ID="MainContent" Runat="Server" ContentPlaceHolderID="MainContentPlaceHolder">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="domainUserID" runat="server" Visible="false"></asp:TextBox>
<!-- gray bar and title -->
<table style="width:100%; border-style:none;">
<tr>
<td class="com_headline">
SQL Emergency Request [Home]
</td>
</tr>
<tr class="com_app_instructions">
<td>
<p>Words here</p>
</td>
</tr>
</table>
<!-- end title and gray bar -->
<asp:Panel ID="panelForm" runat="server" Visible="True" CssClass="myform">
<form method="post" action="Default.aspx" id="form">
<h1>Request Form</h1>
<p>Complete this form to be issued a login</p>
<table cellpadding="5px">
<tr>
<td>
IR Number
<br />
<span class="small">Obtain your IR number from
SMART</span>
</td>
<td>
<asp:TextBox ID="txtIR" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtIR" CssClass="errorMsg"
ErrorMessage="Please Enter Your IR Number">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Server
<br />
<span class="small">MSSQL5 is supported for now</span>
</td>
<td>
<asp:DropDownList ID="ddServer" runat="server" AutoPostBack="True"
Enabled="False" onselectedindexchanged="ddServer_SelectedIndexChanged">
<asp:ListItem>DEVMSSQL05</asp:ListItem>
<asp:ListItem Selected="True">MSSQL05</asp:ListItem>
</asp:DropDownList>
</td>
<td>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
ControlToValidate="ddServer" CssClass="errorMsg"
ErrorMessage="Please Choose A Server">
</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Database
<br />
<span class="small">You have the role of 'Analyst' in these databases</span>
</td>
<td>
<asp:DropDownList ID="ddDatabase" runat="server" AppendDataBoundItems="true"
AutoPostBack="false" DataSourceID="DatabaseDropDownObjectDataSource"
DataTextField="DatabaseName" DataValueField="DatabaseName" Width="150">
</asp:DropDownList>
</td>
<td>
</td>
</tr>
<tr>
<td></td>
<td>
<asp:Button ID="Button1" runat="server" CssClass="com_btn_flat"
onclick="Button1_Click" Text="Submit" />
</td>
<td>
<div id="loader">loading...</div>
</td>
</tr>
</table>
</form>
</asp:Panel>
<asp:Panel ID="PanelError" runat="server" Visible="false" CssClass="errorPanel">
<h1><asp:Label ID="txtErrorMsg" runat="server">error text</asp:Label></h1>
</asp:Panel>
<br />
<asp:Panel ID="panelOutput" runat="server" Visible="false" CssClass="panelOutput">
<h1>
<asp:Literal ID="Title" runat="server" Text=""/>
</h1>
<p>
<asp:Literal ID="Warning" runat="server" Text=""/>
</p>
<p>
<asp:Literal ID="LoginLifeHours" runat="server" Text=""/>
</p>
<p>
<span class="important">
<asp:Literal ID="Login" runat="server" Text="" />
</span>
</p>
<p>
<span class="important">
<asp:Literal ID="PWD" runat="server" Text="" />
</span>
</p>
<br />
<p>
<asp:Button ID="Button2" runat="server" Text="Request Another Login"
onclick="Button2_Click" CssClass="com_btn_flat" />
</p>
</asp:Panel>
This is the button that is not responding in IE
<p>
<asp:Button ID="Button2" runat="server" Text="Request Another Login"
onclick="Button2_Click" CssClass="com_btn_flat" />
</p>

The problem is that you are using a <form> tag within your content page. The master page already includes a <form> tag and IE appears to be balking at the form within a form. When I removed the <form> tag from your aspx, the button handler ran under IE8.

The sample code is Button2_Click, but your button markup outside of the panels has test_button_Click as the event handler? There are three buttons, so which one are you asking about, I assume the last?

I noticed that you have a tag inside your first panel (panelForm). Also, I don't see a a tag with a runat="server" attribute (although, it could be in a master page). And it doesn't look like your button is inside a form (unless the master page has a form).
The problem is that you can only have one form on a page in Asp.NET WebForms. If you don't have any <form runat="server"> tags on your page, then you buttons will not fire any events on the code-behind.

Related

Unusable elements inside the (list view ) asp.net

Why can't I use the (input) I put in my (list view) in the C # code field?
<asp:ListView ID="ListV" runat="server">
<ItemTemplate runat="server">
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<tr class="text-center">
<td class="product-remove"></td>
<td class="image-prod">
<div class="">
<asp:Image ID="Image1" CssClass=" img" ImageUrl='<%# "../img/" + Eval("picture")
%> ' runat="server" />
</div>
</td>
<td class="product-name"><%# Eval("namebook") %> </td>
<td class="price"><%# Eval("Price") %> </td>
<td class="quantity"><%# Eval("titel") %></td>
<td class="col-2">
<asp:Button ID="delete" CssClass="btn btn-outline-danger" CommandArgument='<%#
Eval("id")%>' OnClick="delete_Click" runat="server" Text="حذف کالا" />
</td>
<td>
<input id="quantity2" runat="server" type="number" value="1" min="1" max="20" />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
You want a server control there. Additionally, this control only exists as part of an item template, meaning there isn't just one control named quantity2... there could be many, depending on the data source. Therefore referencing it just by name is not good enough. And speaking of data sources, depending on how you handle this the databinding may not have taken place yet at the time the Page_Load code runs, meaning the input control doesn't exist at all.
So the real question is: what do you want to do with this input?
CodeBehind="~/ (Page Name) .aspx.cs"

Unable to check RadioButton inside DataList footer Template

I have kept two radio button inside a datalist footer template but I am not at all able to select it. Below is my footer template:
<FooterTemplate>
<tr>
<td align="right" colspan="7"><br />
</td>
</tr>
<tr>
<td align="left" valign="middle" colspan="7">
<div style="background-color:#FCEE21; height:47px ;">
<div style=" position:relative; top:15px; left:20px;">
<asp:CheckBox ID="cbAgree" Checked="true" Text="I agree on all terms & conditions" runat="server" />
</div>
<div style=" position:relative; top:-1px; left:410px;">
<asp:Label ID="Label2" runat="server" Text="Total: (INR)"></asp:Label>
</div>
<div style=" position:relative; top:-22px; left:550px;">
<asp:Label ID="lbltotal" runat="server" Text="000000" Font-Size="14pt"></asp:Label>
</div>
</div>
</td>
</tr>
<tr>
<td align="right" colspan="7">
<div style="background-image: url(images/footerBg.png); height:47px ;">
<div style=" position:relative; top:10px; left:-172px;">
<asp:Label ID="Label9" runat="server" Text="Select an option: "></asp:Label>
<asp:RadioButton ID="rb1" Text="Colect" AutoPostBack="true" runat="server" GroupName="rboption"/>
<asp:RadioButton ID="rb2" Text="Deliver" AutoPostBack="true" runat="server" GroupName="rboption"/>
</div>
<div style=" position:relative; top:-18px;">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" BackColor="#F8CD20" CssClass="anchor"
BorderColor="#F8CD20" BorderStyle="None" OnClick=" Submit_Clicked" Font-Bold="True" Font-Size="14pt"
Height="38px" Width="105px" />
</div>
</div>
</td>
</tr>
</FooterTemplate>
I have not done any databinding also. Please help me out, if I missed out something.
Your problem is about your css styling. If you remove inline css styles from your divs you can click them.
Those divs are displaying on top of each other without proper styles and radiobuttons stay under another div, prevents you clicking on them.
Or if you want to keep the styles and still click them you can use "z-index" attribute with adding z-index:1;, so you bring the div with radiobuttons, above the other div, making them clickable.
....
<div style=" position:relative; top:10px; left:-172px; z-index:1;">
<asp:Label ID="Label9" runat="server" Text="Select an option: "></asp:Label>
<asp:RadioButton ID="rb1" Text="Colect" AutoPostBack="true" runat="server" GroupName="rboption"/>
<asp:RadioButton ID="rb2" Text="Deliver" AutoPostBack="true" runat="server" GroupName="rboption"/>
</div>
....

Image tag not updating inside the UpdatePannel

I hope you are coding well,
I am working on a Image Upload module , which is in a Modal Popup and hence is wrapped inside an Update Panel,
<asp:UpdatePanel runat="server" ID="UpdateModelPopup" UpdateMode="Conditional" ChildrenAsTriggers="true">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="lnkUploadImage" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:Panel runat="server" ID="pnlModel" CssClass="ModalWindow">
<!-- Style="display: none;" -->
<table border="0" class="modalTable" cellspacing="5">
<tr>
<td>
Keywords 2<strong><font color="#FF0000">*</font></strong> <i>(Seperated by , )</i>
<br />
<asp:TextBox runat="server" ID="txtKeywordsTwo"></asp:TextBox><br />
</td>
<td>
Dimensions <strong><font color="#FF0000">*</font></strong>
<br />
Width :
<asp:TextBox ID="txtDimWidth" runat="server" Width="50px"></asp:TextBox>
Height :
<asp:TextBox ID="txtDimHeight" runat="server" Width="50px"></asp:TextBox>
</td>
<tr>
<td colspan="2">
<hr />
</td>
</tr>
<tr>
<td>
Browse .psd file<br />
<ajaxToolkit:AsyncFileUpload runat="server" ID="pdfFile" Width="200px" OnUploadedComplete="pdfFile_UploadedComplete"
CompleteBackColor="" ErrorBackColor="" OnClientUploadComplete="Success" />
<asp:Image runat="server" ID="imgThumbNail" /><br />
<font color="#FF0000">or</font><br />
Refrence URL<br />
<asp:TextBox ID="TextBox11" runat="server"></asp:TextBox>
</td>
<td>
Browse file <i>(.jpeg, .gif or .png)</i><strong><font color="#FF0000">*</font></strong><br />
<ajaxToolkit:AsyncFileUpload runat="server" ID="AsyncFileUpload1" Width="200px" />
</td>
</tr>
</table>
<asp:Button runat="server" ID="btnUpload" Text="Upload" CssClass="btn" OnClick="btnUpload_Click" />
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
Now as per the business requirement, I need to show a thumbnail of the Image that user uploads, and for .psd file I have a standard icon which I display's at the run time, in the code behind I am validating the file extension to be the .psd file and it is then display the psd icon, I am trying to set the ImageURL for
protected void pdfFile_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{
if (Path.GetExtension(e.FileName).ToString().ToLower() != ".psd")
{
string alertMsg = #"alert('Please provide .PSD type file');";
ScriptManager.RegisterStartupScript(this, this.GetType(), "Test", alertMsg, true);
//pdfFile
}
else
{
imgThumbNail.ImageUrl ="~/images/psdIcon.jpg";
}
}
The problem is that Panel doesnt gets update at the run time, even the page source shows src="". I am suspecting that its a Update Panel issue.
Kindly point me into the right direction.
Thanks in advance
FileUpload can not be done Asynchronously. In order to do that PostBackTrigger Trigger will be required to upload.

text box have it,s text from DDl

I have a drop-down list which gathers data from the database and a textbox which contains the text from the drop-down list when I select a value from the drop-down list. I tried to make this work, but no data appears in the textbox when I select a value from the drop-down list and no errors appear either. Can anyone help me?
aspx Code:
<table id="Tbl" runat="server" width="70%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td>
Select
</td>
<td>
<asp:SqlDataSource ID="SDSOption" runat="server" ConnectionString="Data Source=ELARABY-1EACFA3\SQLEXPRESS;Initial Catalog=ElarabyGroup;Integrated Security=True"
ProviderName="System.Data.SqlClient" SelectCommand="SELECT [Id], [option] FROM [Option]">
</asp:SqlDataSource>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SDSOption" DataTextField="option"
DataValueField="Id" ondatabound="DropDownList1_DataBound"
onselectedindexchanged="DropDownList1_SelectedIndexChanged">
</asp:DropDownList>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
</td>
<td>
<b style="font-style: italic">Select Option</b> <b style="font-style: italic">
<br />
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtOption"
Display="Dynamic" ErrorMessage="*" SetFocusOnError="True"><b style="font-style: italic">*</b></asp:RequiredFieldValidator>
</b>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="LblOption" runat="server" Text="Option"></asp:Label>
</td>
<td class="style1">
<asp:TextBox ID="TxtOption" runat="server"></asp:TextBox>
</td>
<td>
<b style="font-style: italic">Note:Add Here Product Option</b> <b style="font-style: italic">
<br />
<asp:RequiredFieldValidator ID="RVOption" runat="server" ControlToValidate="TxtOption"
Display="Dynamic" ErrorMessage="*" SetFocusOnError="True"><b style="font-style: italic">*</b></asp:RequiredFieldValidator>
</b>
</td>
</tr>
<tr style="font-style: italic">
<td class="style2">
</td>
<td>
<asp:Button ID="BtnSubmit" runat="server" Height="20px" Text="Submit" Width="50px"
OnClick="BtnSubmit_Click" />
</td>
<td align="left">
<b><i><span><a href="EditOption.aspx">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Backend/Image/www_4photos_net_1137678404.jpg"
Width="60px" /></a> Display Other </span></i></b>
</td>
</tr>
</table>
CS Code:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
TxtOption.Text += DropDownList1.SelectedItem.Value;
}
The DropDownList is wrapped in an UpdatePanel, but the TextBox is not.
What this means is during the asychronous postback (triggered on the SelectedIndexChanged event), the postback only has visiblity of the controls inside the UpdatePanel (as this is all that gets submitted to the server).
Because the TextBox is outside the UpdatePanel, it does not have visibility of it during the async postback.
The easiest solution would be to put the Textbox inside the UpdatePanel.
Another solution would be to use ScriptManager.RegisterStartupScript to set the value of the control from the SelectedIndexChanged event using basic JavaScript (which has access to the entire DOM, unlike the asynchronous postback).
E.g
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(UpdatePanel1,
this.GetType(),
"NameOfScript",
string.Format("document.getElementById('{0}').value = '{1}';",
txtOption.ClientId,
DropDownList1.SelectedValue));
}

UpdateProgress and FileUpload problem

I have a fileupload control with an updatePprogress in an updatePanel like this:
UpdatePanel is: updExtraSmall
<Triggers>
<asp:PostBackTrigger ControlID="lnkExtraSmall" />
</Triggers>
<ContentTemplate>
<table>
<tr>
<td style="border: 1px">
<asp:FileUpload ID="fupldExtraSmall" runat="server" />
</td>
<td>
<asp:LinkButton ID="lnkExtraSmall" OnClientClick="javascript:showWait();" OnClick="lnkExtraSmall_click" CausesValidation="false"
runat="server" Text="Upload" />
<asp:Label ID="lblMessage" runat="server" />
</td>
<td>
<asp:Label ID="lblExtraSmallMessage" runat="server" />
</td>
<td>
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="updExtraSmall">
<ProgressTemplate>
<DIV id="IMGDIV" align="center" valign="middle" runat="server" style="position: absolute;left: 35%;top: 25%;visibility:visible;vertical-align:middle;border-style:inset;border-color:black;background-color:White">
<img src="loading/loading.gif" /><br />
</DIV>
</ProgressTemplate>
</asp:UpdateProgress>
</td>
</tr>
</table>
</ContentTemplate>
and:
function showWait()
{
if ($get('fupldExtraSmall').value.length > 0)
{
$get('UpdateProgress1').style.display = 'block';
}
}
The problem is that the updateProgrss doesn't show.
Can anyone help me please?
Thank you,
Alina
Just Use the asyncfileupload control which come with ajaxcontroltoolkit 3.0 and then upload the file.
Put the UpdateProgress outside the ContentTemplate.
Ref: http://msdn.microsoft.com/en-us/library/bb398821.aspx

Categories

Resources