asp.net ajax doesn't keep textarea values in async postback - asp.net

I have a dialog popup with a textearea, two listboxes and one button. By selecting a value in the first listbox and pressing the button ">" the selected value is passed to the second listbox. This is done with asp.net ajax.
<td>
<div align="center">
<textarea style="height:50px; overflow:hidden;";rows="20"
cols="40"
id="editor1"
class="tinymce">
</textarea>
</div>
</td>
I put the 2 listboxes and the button between asp.net uploadpanel. Like this:
<td>
<asp:UpdatePanel runat="server" id="updatePanel1">
<ContentTemplate>
<table width="100%" align="left">
<tr>
<td colspan="5">
<hr align="left" style="width:95%" />
</td>
</tr>
<tr>
<td valign="top">
<cc1:SWCListBox
ID="SWCListBox1"
runat="server"
Width="100"
SelectionMode="Single"
CssClass="VW1">
</cc1:SWCListBox>
</td>
<td
valign="top"
width="50"
align="center">
<cc1:SWCButton
Text=" > "
ID="SWCBtnAddValue"
CssClass="VW1 VWButton"
runat="server"
ToolTip="Add to list"
OnClick="AddValue_Click"
CausesValidation="false"
/>
<td valign="top">
<cc1:SWCListBox
id="SWCListBox2"
CssClass="VW1"
runat="server"
Width="100"
SelectionMode="Single"
/>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
The probles is that when I type something in the textarea and make an async postback the text typed fades.
How can I keep the textarea value within async postbacks?
thank you.

This problem is because you use UpdatePanel, and the textarea is not an asp.net control. You have two solutions.
1) Make it asp.net control by placing the run="server" (or)
2) Place the post back value manually as:
<div align="center">
<textarea style="height:50px; overflow:hidden;";rows="20"
cols="40"
id="editor1"
name="editor_1"
class="tinymce">
<asp:Literal runat="server" id="txtEditor1" />
</textarea>
</div>
and on code behind
txtEditor1.Text = Server.HtmlEncode(Request.Form["editor_1"].ToString());
(because you use UpdatePanel its important to use Literal to add this value and not use <%=%>, or else its throw an error.

Related

target panel of CollapsiblePanelExtender not visible on load, need to collapse then expand to see it

I have inherited an app that has a CollapsiblePanelExtender. The codebehind populates the control that's inside the panel when it loads. I set the CollapsiblePanelExtender to be expanded in the codebehind, but the target panel isn't visible, even though the CollapsiblePanelExtender is expanded.
If I then collapse the CollapsiblePanelExtender, and then expand it again, the panel shows up. The html is there, but it isn't showing.
Any clues would be appreciated, thanks.
<div class="contentBoxTitle">
<asp:Panel ID="expandCTL" runat="server" Width="100%">
<asp:Image ID="expandIMG" ImageUrl="~/images/itemOpen.gif" runat="server" />
Client
</asp:Panel>
</div>
<asp:Panel ID="profilePanel1" runat="server" >
<div class="profileTable">
<table width="350" border="0" cellpadding="2" cellspacing="0">
<tr bgcolor="ffffff">
<th width="100" height="20" bgcolor="ffffff"><div align="right">Name:</div></th>
<td>
<asp:Label ID="name" runat="server" Text=""></asp:Label> </td>
</tr>
...
(more fields here)
...
</table>
</div>
</asp:Panel>
</div>
<ajaxToolkit:CollapsiblePanelExtender runat="server" TargetControlID="profilePanel1" CollapsedSize ="1" ID="profilePanelCollapser"
ExpandDirection="Vertical" ImageControlID="expandIMG" ExpandedImage="~/images/itemOpen.gif"
CollapsedImage="~/images/itemClosed.gif" Collapsed="false" ExpandControlID="expandCTL" CollapseControlID="expandCTL" />

asp:Button causing Server Error in SharePoint

I have a button which has probably been implemented wrong, since it causes an error 500. The page works fine without the button and I'm not sure where the problem lies.
The .aspx:
<asp:Content ID="Main" ContentPlaceHolderID="PlaceHolderMain" runat="server">
<div id="notify_form">
<p>Please enter a new email:</p>
<table class="ms-formtable" width="100%">
<tr>
<td><input type="text" runat="server" id="txtEmail"/></td>
</tr>
<tr>
<td class="ms-formlabel"></td>
<td>
<asp:Button runat="server" ID="btnSubmit" OnClick='SaveEmail' />
<asp:Button runat="server" ID="btnCancel" OnClientClick="window.frameElement.cancelPopUp(); return false;"/>
</td>
</tr>
</table>
</div>
</asp:Content>
The SaveEmail method does nothing at the moment.

Issues with Devexpress Grid

I am using a devexpress grid with editform template. When I click on the edit button, this edit form is displayed. The edit form has an Update and Cancel button at the bottom of the form. I want to set the focus on the cancel button when this edit form is opened. Is it possible to set the focus on either update/cancel buttons when this edit form is opened?
You can use template for Edit Form and Specify The TabIndex Property For The Buttons :
I have attached sample example for your reference.
If any question, feel free to ask.
<Templates>
<EditForm>
<table style="width: 100%">
<tr>
<td align="right">
<dx:ContentControl ID="ContentControl" runat="server" SupportsDisabledAttribute="True">
<dx:ASPxGridViewTemplateReplacement runat="server" ID="Editors" ReplacementType="EditFormEditors" />
</dx:ContentControl>
<table style="width: 100%;">
<tr>
<td align="right" style="padding-right: 20px">
<table>
<tr>
<td>
<dx:ASPxButton ID="btnUpdate" runat="server" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" TabIndex="0"
AccessKey="S" AutoPostBack="False" Text="Update" Width="60px" ClientSideEvents-Click='<%# "function(s, e) { " + Container.UpdateAction + " }" %>'
CssPostfix="Office2010Blue" SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css" >
</dx:ASPxButton>
</td>
<td>
<dx:ASPxButton ID="btnCancel" runat="server" CssFilePath="~/App_Themes/Office2010Blue/{0}/styles.css" TabIndex="1"
AutoPostBack="False" Text="Cancel" Width="60px" ClientSideEvents-Click='<%# "function(s, e) { " + Container.CancelAction + " }" %>'
CssPostfix="Office2010Blue" SpriteCssFilePath="~/App_Themes/Office2010Blue/{0}/sprite.css">
</dx:ASPxButton>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</EditForm>
</Templates>
please use the approach described in the ASPxGridView inline editing "tab order" report.
http://www.devexpress.com/Support/Center/Question/Details/Q218510
If you place your own editors in the EditForm template, set the TabIndex property of each editor according to your requirements.

Asp.net Login Control, render only the server side controls without the HTML

The Login Control does not render the html under the layout template,it render only the server side controls,
this is the markup:
<asp:Login ID="Login11" EnableTheming="false" runat="server" MembershipProvider="SqlProvider"
OnLoginError="Login11_LoginError" LoginButtonType="Link">
<LayoutTemplate>
<div class="login-box">
<div>
<table cellpadding="10" cellspacing="0">
<tr>
<td>
User name:
</td>
<td>
<asp:TextBox ID="UserName" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Password:
</td>
<td>
<asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
Forgot Password?
</td>
</tr>
<tr>
<td colspan="2">
<asp:CheckBox ID="RememberMe" runat="server" Text="Remember my password"></asp:CheckBox>
</td>
</tr>
</table>
</div>
<div>
<asp:LinkButton ID="LoginBtn" CommandName="Login" runat="server" CssClass="login-btn">Login</asp:LinkButton>
</div>
<div>
<asp:Literal ID="FailureText" runat="server"></asp:Literal>
</div>
</div>
</LayoutTemplate>
</asp:Login>
And the output is :
<input name="ctl00$ContentPlaceHolder1$Login11$Password" id="ctl00_ContentPlaceHolder1_Login11_Password" type="password">
<input id="ctl00_ContentPlaceHolder1_Login11_RememberMe" name="ctl00$ContentPlaceHolder1$Login11$RememberMe" type="checkbox">
<label for="ctl00_ContentPlaceHolder1_Login11_RememberMe">Remember my password</label>
<a id="ctl00_ContentPlaceHolder1_Login11_LoginBtn" class="login-btn" href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$Login11$LoginBtn','')">Login</a>
Why this Happen ?!
I had the same problem and I was going almost crazy or something. Until I saw your question. Then I though, I am not the only one to stumble upon this bug.
I don't know why is this happening, but your question includes the solution (or better, the workaround)
I see you have a div there (class="login-box") at the top of the hierarchy. I suppose setting the runat attribute (runat="server") will solve the problem.
At least that is what I did, except I had a table, not a div at the top of my hierarchy. Making the table run at the server side (meaning there is actually an HtmlTable control added to the template's Controls collection), fixed the problem, and I didn't need to set any other client side elements below this table, to run at server side. Only the top element needed the runat attribute.
After removing the following:
<%=Util.BaseUrl %>
from the HTML tag
Forgot Password?
the layout template has rendered correclty.

Refresh gridview inside update panel after modal popup closes

I'm having a heck of a time trying to get a gridview to refresh its data after a modalpopup adds a new record to the database. Ive tried the following with no luck.
<cc2:ModalPopupExtender ID="mdlPopup" runat="server" OnOkScript="__doPostBack('<%= gvRecommendations.ClientID %>', '');" BackgroundCssClass="modalBackground"
TargetControlID="lbtnRecommendationsAddNew" PopupControlID="pnlAddNewRecommendation">
</cc2:ModalPopupExtender>
<asp:Panel ID="pnlAddNewRecommendation" runat="server" CssClass="confirm-dialog" style="display:none;" Width="500px">
<div class="inner">
<h2>New Suppressed Recomendation</h2>
<div class="base">
<table width="100%" cellpadding="5" cellspacing="0">
<tr>
<td align=left>
<asp:DropDownList ID="ddlRecomendations" runat="server" />
</td>
</tr>
<tr>
<td align="left">
<asp:Button ID="btnAddRecommendation" OnClick="btnAddRecommendation_Click" runat="server" Text="Submit" />
|
<asp:LinkButton ID="btnCancel" runat="server" Text="Cancel" ForeColor="Blue" />
<asp:LinkButton id="lbtnTopLeft" runat="server" CssClass="close" />
</div>
</td>
</tr>
</table>
</div>
</div>
</asp:Panel>
Ive also tried adding this with no luck after adding the record to the DB:
this.gvSupressedRecommendations.DataBind();
this.UpdatePanel1.Update();
I know im close but can't seem to get this to refresh.
Try reassigning your datasource before you rebind. This should work. I.e.
gvSupressedRecommendations.DataSource = <...>;
gvSupressedRecommendations.DataBind();

Resources