Not able to select text in textbox - asp.net

I've got this here wizard step with a couple of text boxes. For some reason I cannot highlight/select the text in the textbox in IE or FF and I have no idea why, not even after spending a couple of hours googling the problem. I could really use another set of eyes on this. Let me know if you need more code to help.
<asp:WizardStep ID="wsPlanInfo" runat="server" Title="" StepType="Step">
<div style="width:100%; height:290px; margin-top:150px ">
<table border="0" style="margin:0 auto;">
<tr>
<td colspan="2" class="title">
Placeholder text here?
</td>
</tr>
<tr>
<td colspan="2"><asp:TextBox runat="server" ID="txtLearningPlanName" Width="300px" CssClass="input-text" /> <asp:RequiredFieldValidator runat="server" ID="rflLearningPlanName" ControlToValidate="txtLearningPlanName" ErrorMessage="*" CssClass="validator" /><br /><br /></td>
</tr>
<tr>
<td colspan="2" class="title">
placeholder text here?
</td>
</tr>
<tr>
<td> </td>
<td>
<table border="0"><tr><td><asp:RadioButton runat="server" ID="rbSpecificDate" GroupName="DeadlinePicker" Checked="true" /></td><td><UC:DatePicker runat="server" ID="ucSpecificDatePicker" RequiredField="false" /></td></tr></table>
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:RadioButton runat="server" ID="rbCustomUserFieldPlusDays" GroupName="DeadlinePicker" /> <asp:DropDownList runat="server" ID="ddlUserCustomFields" CssClass="input-text" /> plus <Telerik:RadNumericTextBox runat="server" SkinID="Normal" ID="rntbUserCustomFieldOffset" ShowSpinButtons="true" DataType="System.Int32" NumberFormat-DecimalDigits="0" Width="60px" Value="365" /> days
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:RadioButton runat="server" ID="rbPlusDays" GroupName="DeadlinePicker" /> <Telerik:RadNumericTextBox runat="server" SkinID="Normal" ID="rntbPlusDays" ShowSpinButtons="true" DataType="System.Int32" NumberFormat-DecimalDigits="0" Width="60px" Value="365" /> days from today
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:RadioButton runat="server" ID="rbNone" GroupName="DeadlinePicker" /> None
</td>
</tr>
</table>
</div>
</asp:WizardStep>

Try:
((TextBox)wsPlanInfo.FindControl("txtLearningPlanName")).Text
It will search the Wizard Step's Control list for a textbox with that ID name. It then casts it as a TextBox and so you can then use the Text property.

Removing disableSelection(document.body) in my javascript solved my problem. Note to self, post entire code when asking a question.

Related

Not able to see radio button list in my screen

I am unable to see the radio button list yes or NO in my screen I am getting the values from XML file.
Following code in aspx page:
<asp:Panel ID="pnlAction" runat="server" Width="100%" Visible="false">
<table cellpadding="0" cellspacing="0" border="0" width="99%">
<tr style="height: 20px;">
<td style="width: 25px;">
<hr />
</td>
<td class="secHeading frmlblBold"" style="width: 80px;" align="center">
Action
</td>
<td>
<hr />
</td>
</tr>
</table>
<table style="font-weight:normal" width="100%" border="0" cellpadding="2" cellspacing="2">
<tr>
<td style="width:250px;"></td>
<td style="width:350px;"></td>
<td style="width:250px;"></td>
<td style="width:350px;"></td>
</tr>
<tr>
<td class="frmlblBold" style="text-align:right;vertical-align:top">Action </td>
<td><asp:DropDownList ID="ddlAction" runat="server" CssClass="DropDown" DataSourceID="dsAction" DataValueField="CODE" DataTextField="CDDesc" AutoPostBack = "False" Width="342px"></asp:DropDownList></td>
</tr>
<tr>
<td class="frmlblBold" style="text-align:right;vertical-align:top">Service Agreement Clause </td>
<td style="vertical-align:top" style="width: 350px;">
<%-- <fieldset id="fldSLA" runat="server" style="width: 280px;">--%>
<asp:RadioButtonList ID="radSLA" runat="server" RepeatDirection="Horizontal" DataValueField="SLAID" DataTextField="SLADESC" DataSourceID="dsSLA" visible = "true">
</asp:RadioButtonList>
<asp:RequiredFieldValidator ID="rfvSLA" runat="server" ControlToValidate="radSLA" ErrorMessage="Please select if service agreement is applicable or not."
Enabled="true" Display="none"></asp:RequiredFieldValidator>
<%-- </fieldset>--%>
</td>
</tr>
<tr>
<td class="frmlblBold" style="text-align:right;vertical-align:top">Comments </td>
<td style="vertical-align:top">
<asp:TextBox runat="server" ID="txtActionComments" MaxLength="500" TextMode="MultiLine" width="95%" Rows="5" /> </td>
</tr>
<tr>
<td align="center" colspan="2">
<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click" CssClass="btnOther" />
</tr>
</asp:Panel>
<asp:XmlDataSource ID="dsSLA" runat="server" EnableCaching="false" DataFile="~/XML/VisaTracking.xml"
XPath="BVILetter/SLA/ITEM" />
Code in .cs file:
if (!IsPostBack)
{
base.PageLoad();
GetReqPndActTknByMe(base.LogShortID);
radSLA.DataBind();
radSLA.SelectedValue = "Yes";
BindDataToDropdownListAction();
}
I am able to see the row count of radSLA.DataBind(); as '2'
My XML code:
<BVILetter>
<SLA>
<ITEM SLAID ="Yes" SLADESC ="Yes" />
<ITEM SLAID ="No" SLADESC ="No" />
</SLA>
</BVILetter>
But I am not able to see the radio buttons in my screen:
Please help me.
Please Check the Binding function clearly. If binding not happened properly then RadioBottonList does not appear.RadioBottonList apear only when when listItem bind properly

UpdatePanel alignment issue inside the Table

I am using UpdatePanel control in the middle of the page for partial postback of Address Type radio button change. Everything works fine but I am struggling with alignment issue. The controls inside the UpdatePanel do not align with outside controls. How could I solve this issue? Please let me know.
<table id="tblEdit" class="cssclass1" cellpadding="3" runat="server">
<tr>
<td class="cssclass1" align="right">
Title
</td>
<td>
<telerik:RadTextBox ID="textbox1" runat="server" Width="280px" ReadOnly="true"
BackColor="LightGray" />
</td>
<td align="right">
<asp:Label CssClass="cssclass1" ID="LblFirstName" runat="server">First Name</asp:Label>
</td>
<td align="left">
<telerik:RadTextBox ID="txtFirstName" runat="server" MaxLength="30">
</telerik:RadTextBox>
<asp:Image ID="Image1" ImageUrl="../../../images/requiredfield.gif" AlternateText="Required Field"
runat="server"></asp:Image><asp:HiddenField ID="hfCaseEntityId" runat="server" />
</td>
</tr>
<tr>
<td colspan="4">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<tr>
<td class="cssclass1" align="right">
Address Type
</td>
<td align="left">
<asp:RadioButtonList ID="AddressType" runat="server" RepeatDirection="Horizontal" OnSelectedIndexChanged="AddressType_SelectedIndexChanged" AutoPostBack="true" >
<asp:ListItem Value="1" Selected="True">Home</asp:ListItem>
<asp:ListItem Value="2">Work</asp:ListItem>
</asp:RadioButtonList>
</td>
<td class="cssclass1" align="right">
</td>
<td align="left">
</td>
</tr>
<tr>
<td align="right">
<asp:Label CssClass="cssclass1" ID="LblHomeStreet1" runat="server">Address</asp:Label>
</td>
<td align="left">
<telerik:RadTextBox ID="txtHomeStreet1" runat="server" MaxLength="40" >
</telerik:RadTextBox>
<asp:Image ID="Image10" ImageUrl="../../../images/requiredfield.gif" AlternateText="Required Field"
runat="server"></asp:Image>
</td>
<td align="right">
<asp:Label CssClass="cssclass1" ID="LblHomeStreet2" runat="server">Street 2</asp:Label>
</td>
<td align="left">
<telerik:RadTextBox ID="txtHomeStreet2" runat="server" MaxLength="40" Width="280px">
</telerik:RadTextBox>
</td>
</tr>
<tr>
<td align="right">
<asp:Label CssClass="cssclass1" ID="LblHomeCity" runat="server">City</asp:Label>
</td>
<td align="left">
<telerik:RadTextBox ID="txtHomeCity" runat="server" MaxLength="30">
</telerik:RadTextBox>
</td>
<td align="right">
<asp:Label CssClass="cssclass1" ID="LblHomeState" runat="server">State</asp:Label>
</td>
<td align="left">
<telerik:RadTextBox ID="txtHomeState" runat="server" MaxLength="30">
</telerik:RadTextBox>
</td>
</tr>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
Your HTML is invalid. The first line in your <ContentTemplate> is a <tr>, however, it looks like you are trying to include another <table> there. You might want to look into cellpading=0 and cellspacing=0 on your inner table. Also, you could add a CSSClass to your UpdatePanel to do any additional formatting.

Modal popup extender not displaying popup

I have inherited some code using an ASP modal popup extender and for some reason it has now decided to stop working. Am I missing anything here? I'm not too fluent with AJAX / ASP.Net right now so im struggling to diagnose what is going wrong here.
So firstly the javascript method that displays the modal
function ShowModalRemoveEvent(ID, EventID, InstructorID, InstructorName)
{
alert("Hi");
var modal = $find('ModalPopupExtender1');
modal.show();
document.getElementById("txtID").value = ID;
document.getElementById("txtEventID").value = EventID;
document.getElementById("txtInstructorID").value = InstructorID;
document.getElementById("txtInstructorName").value = InstructorName;
}
I know this is being called because of the alert. So I would assume the prpblem is either in finding the ModalPopupExtender1 or the modal.show() line.
Here is the code for my modal popup extender
<asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Panel ID="Panel4" runat="server" Style="display: none" CssClass="ModalBackground">
<table style="width: 100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="7%" class="cellAlertHeader">
<img src="../../../images/Ops/window_delete.png" style="width: 18px; height: 18px" alt=""/>
</td>
<td width="93%" class="cellAlertHeader">
<b>Cancel Instructor Event</b>
</td>
</tr>
</table>
<table width="100%">
<tr>
<td width="5%">
<td width="95%">
<asp:TextBox ID="txtID" Style="display: none" runat="server" CssClass="TextboxTitle"></asp:TextBox>
<asp:TextBox ID="txtEventID" Style="display: none" runat="server" CssClass="TextboxTitle"></asp:TextBox>
</td>
</tr>
<tr>
<td width="5%">
</td>
<td width="95%">
<asp:TextBox ID="txtInstructorID" Style="display: none" runat="server" BorderStyle="None"
CssClass="TextboxTitle"></asp:TextBox>
<asp:TextBox ID="txtInstructorName" Style="font-size: 12px" runat="server" BorderStyle="None"
CssClass="TextboxTitle" BorderWidth="0"></asp:TextBox>
</td>
</tr>
<tr>
<td width="5%">
</td>
<td width="95%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td width="95%">
<asp:Label ID="Label2" runat="server" Text="Are you sure you want to remove this Event?"
CssClass="TextboxTitle"></asp:Label>
</td>
</tr>
<tr>
<td width="5%">
</td>
<td width="95%">
</td>
</tr>
<tr>
<td width="5%">
</td>
<td width="95%">
<asp:Button ID="ButtonConfirmRemove" runat="server" Text="Confirm" CssClass="buttonshort" />
<asp:Button ID="ButtonCancel" runat="server" Text="Cancel" CssClass="buttonshort" />
</td>
</tr>
<tr>
<td width="5%">
</td>
<td width="95%">
</td>
</tr>
</table>
</asp:Panel>
<asp:Button runat="server" ID="dummyButton" Style="display: none" />
<cc1:ModalPopupExtender ID="ModalPopupExtender1"
runat="server"
PopupControlID="Panel4"
TargetControlID="dummyButton"
BackgroundCssClass="ModalBGOpacity"
CancelControlID="ButtonCancel"
OnCancelScript="HideModalPopup()">
</cc1:ModalPopupExtender>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="dummyButton" />
</Triggers>
</asp:UpdatePanel>
Try getting the rendered id of your control, like that.
var modal = $find('<%=ModalPopupExtender1.CliendID%>');

Difference between web controls rendering and html table properties using ASP.NET

I'm designing a website in ASP.NET and I want to build table with some text, textboxes and validators in it. The problem is that table looks different in Firefox and IE. Here is an example:
http://www.freeimagehosting.net/image.php?224860e266.png
Here is the table code in ASP.NET:
<table align="center" cellpadding="0" cellspacing="1" style="text-align: right; border-collapse: separate;">
<tr>
<td>
Nadawca:
</td>
<td>
<asp:TextBox ID="TextBoxNadawca" runat="server" Width="250px" BorderStyle="none"
BackColor="#c1ae85"></asp:TextBox>
</td>
<td align="left">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Nadawca jest wymagany."
ControlToValidate="TextBoxNadawca" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Adres e-mail:
</td>
<td>
<asp:TextBox ID="TextBoxMail" runat="server" Width="250px" BorderStyle="none" BackColor="#c1ae85"></asp:TextBox>
</td>
<td align="left">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="E-mail jest wymagany."
ControlToValidate="TextBoxMail" ForeColor="Red"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBoxMail"
ErrorMessage="Nieprawidłowy format." ForeColor="Red" Style="position: absolute;
top: 589px; left: 632px; width: 160px;" ValidationExpression="\w+([-+.']\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td>
Temat:
</td>
<td>
<asp:DropDownList ID="DropDownTemat" runat="server" Style="margin-left: 0px;" Width="250px"
BorderStyle="none" BackColor="#c1ae85">
<asp:ListItem>Reklama w serwisie</asp:ListItem>
<asp:ListItem>Pomysł na rozwój serwisu</asp:ListItem>
<asp:ListItem>Chcę zostać moderatorem</asp:ListItem>
<asp:ListItem>Prawa autorskie</asp:ListItem>
<asp:ListItem>Banicja</asp:ListItem>
<asp:ListItem>Błąd na stronie</asp:ListItem>
<asp:ListItem>Inne</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td>
Treść:
</td>
<td>
<asp:TextBox ID="TextBoxTresc" runat="server" Height="150px" TextMode="MultiLine"
Width="250px" BorderStyle="none" BackColor="#c1ae85"></asp:TextBox>
</td>
<td align="left">
<asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ErrorMessage="Treść jest wymagana."
ControlToValidate="TextBoxTresc" ForeColor="Red"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td style="text-align: center;">
<asp:Button ID="Button1" runat="server" Text="Wyślij" OnClick="Button1_Click" Width="250px"
BorderStyle="None" BackColor="#c1ae85" />
</td>
</tr>
<tr>
<td>
</td>
<td style="text-align: justify">
<br />
<asp:Label ID="Label1" runat="server" Width="250px"></asp:Label>
</td>
</tr>
</table>
Thanks in advice,
Peter.
When i remove your styling code
<table align="center" cellpadding="0" cellspacing="1" style="text-align: right; border-collapse: separate;">
to
<table align="center">
It shows same for IE, Firefox and Chrome. So if you want to style your table ill suggest you to try CSS
Don't use tables for your layout, use CSS. The only time you should use tables is for tabular data. By using CSS here you can omit border-bottom where you are getting the double borders.

Invalid VIewState in ASP.NET page

I have tried to set EnableViewStateMac to false but sometime the aspx page still gets the Invalid ViewState error. Modifying machine.config is impossible in this case. Don't know what to do. Please help!
Here is the ASPX code:
<%# Page Language="C#" MasterPageFile="~/CommonPage.Master" Codebehind="Register.aspx.cs" EnableViewStateMac="false"
Inherits="xxxxxxxx.Register" Title="Create a new Account" %>
<%# Register TagPrefix="usc" Namespace="xxxxxx" Assembly="xxxxxxxx" %>
<%# Register Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" TagPrefix="rad" %>
<asp:Content ID="c" ContentPlaceHolderID="content" runat="Server">
<div class="t_padleft">
<div class="t_failure" runat="server" visible="False" id="divFailure"></div>
<div class="t_success" runat="server" visible="False" id="divSuccess"></div>
<asp:PlaceHolder ID="phRegister" runat="server">
<h2 class="top">
Login Information</h2>
<table class="form">
<tr>
<td class="lbl">
Your Email</td>
<td class="field">
<asp:TextBox ID="txtEmail" runat="server" CssClass="txt"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvEmail" runat="server" ControlToValidate="txtEmail"
Display="Dynamic" ErrorMessage="Please enter your e-mail address."></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="revEmail" runat="server" ValidationExpression="\w+([-+.]\w+)*#\w+([-.]\w+)*\.\w+([-.]\w+)*"
ControlToValidate="txtEmail" Display="Dynamic" ErrorMessage="E-mail address is invalid."></asp:RegularExpressionValidator></td>
</tr>
<tr>
<td class="lbl">
Password</td>
<td class="field">
<asp:TextBox ID="txtPassword" TextMode="Password" runat="server" CssClass="txt"></asp:TextBox></td>
</tr>
<tr>
<td>
</td>
<td>
<asp:RegularExpressionValidator id="revPasswordIsInvalid" runat="server" ErrorMessage="Accepted characters are: a->z, A->Z, _, and 0->9.<br />Password's length must be between 5 to 40"
ControlToValidate="txtPassword" ValidationExpression="\w{5,40}" Display="Dynamic"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="rfvPass" runat="server" ControlToValidate="txtPassword"
Display="Dynamic" ErrorMessage="Please enter password."></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="lbl">
Verify Password</td>
<td class="field">
<asp:TextBox ID="txtVerifyPassword" TextMode="Password" runat="server" CssClass="txt"></asp:TextBox></td>
</tr>
<tr>
<td>
</td>
<td>
<asp:CompareValidator id="cvInvalidConfirmPassword" runat="server" ErrorMessage="The Verify Password does not match the Password"
ControlToValidate="txtVerifyPassword" ControlToCompare="txtPassword" Display="Dynamic"></asp:CompareValidator>
<asp:RequiredFieldValidator ID="rfvConfirm" runat="server" ControlToValidate="txtVerifyPassword"
Display="Dynamic" ErrorMessage="Please enter confirm password."></asp:RequiredFieldValidator>
</td>
</tr>
</table>
<h2>
Your Personal Information</h2>
<table class="form">
<tr>
<td class="lbl">
First Name</td>
<td class="field">
<asp:TextBox ID="txtFirstName" runat="server" CssClass="txt"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ControlToValidate="txtFirstName"
Display="Dynamic" ErrorMessage="Please enter your first name."></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="lbl">
Last Name</td>
<td class="field">
<asp:TextBox ID="txtLastName" runat="server" CssClass="txt"></asp:TextBox></td>
</tr>
<tr>
<td>
</td>
<td>
<asp:RequiredFieldValidator ID="rfvLastName" runat="server" ControlToValidate="txtLastName"
Display="Dynamic" ErrorMessage="Please enter your last name."></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td class="lbl">
Country</td>
<td class="field">
<rad:RadComboBox ID="cbxCountry" runat="server" Width="336px" Height="150px" MarkFirstMatch="true" Skin="UltimateBlack" OffsetX="2"></rad:RadComboBox>
</td>
</tr>
<tr style="padding-top: 4px">
<td class="lblnotrequired">
Company Name</td>
<td class="fieldnotrequired">
<asp:TextBox ID="txtCompany" runat="server" CssClass="txt"></asp:TextBox></td>
</tr>
<tr>
<td class="lbl">
Time Zone</td>
<td class="field">
<rad:RadComboBox ID="cbxTimeZone" runat="server" Width="336px" Height="150px" MarkFirstMatch="true" Skin="UltimateBlack" OffsetX="2"></rad:RadComboBox>
</td>
</tr>
<tr>
<td>
</td>
<td class="formbtn">
<asp:Button ID="btnRegister" runat="server" OnClick="btnRegister_Click" CssClass="btn"
Text="Register" /></td>
</tr>
</table>
</asp:PlaceHolder>
</div>
</asp:Content>
Maybe it will help (us), if you post a example code, e.g. where you are setting EnableViewStateMac.
But for now, it looks like, your field is not correctly initiated, so instead of true/false it has the value "null". But it´s just a guess, recommending more is quiet impossible for now. ;)
I've gotten invalid viewstate errors before, and in researching, I think for me the issue was happening is in one of my really large pages. I read somewhere that really large pages can have that issue happen, for a reason I now forget...

Resources