Note: This is an asp.net page but the XSLT Transformation is occurring client-side.
So I am trying to set a default value in an asp.net textarea and it is being escaped which is causing me problems
Here is the asp.net text area
<asp:TextBox id="Description" TextMode="MultiLine"
Columns="50" Rows="4" runat="server"
ClientIDMode="Static" CausesValidation="false">
<xsl:value-of select="/oohru/form/desc" />
</asp:TextBox>
On the page it becomes
<textarea id="Description" cols="50" rows="4"
name="ctl00$RightColumn$Description">
<xsl:value-of select="/oohru/form/desc" />
</textarea>
Putting in the text area the literally
<xsl:value-of select="/oohru/form/desc" />
I'd like to get the non escaped value in there.... if i Just use a regular text area like
<textarea rows="5" cols="5">
<xsl:value-of select="/oohru/form/desc" />
</textarea>
It works fine.... How can I accomplish this with an ASP.NET control? It's basically breaking my clientside xslt but ONLY on the textarea...
Thanks!
Note: I also did try using the text="{/oohru/form/desc}" inside of the text area... same thing the text area contained that exact oohru/form/desc rather than the referenced value.
You seem to be trying to use XSLT too-late.
My guess is that you want to generate the control with XSLT.
In this case inside your XSLT transformation you'll have:
<asp:TextBox id="Description" TextMode="MultiLine"
Columns="50" Rows="4" runat="server"
ClientIDMode="Static" CausesValidation="false">
<xsl:value-of select="/oohru/form/desc" />
</asp:TextBox>
where you'll also need to bind the prefix asp: to some namespace.
Alternatively, within the XSLT transformation you can generate the textarea directly:
<textarea rows="5" cols="5">
<xsl:value-of select="/oohru/form/desc" />
</textarea>
Final note: If my guesses are wrong and you just want the end-user to see in the textarea the string "<xsl:value-of select="/oohru/form/desc" />", then it doesn't matter that you see it(before being displayed by the browser) escaped -- when the browser displays it, the user will see the unescaped text.
Update: #Jordan has further clarified his transformation is client-side -- way after the asp control has evaporated...
In this case the answer is: No, you cannot generate with the asp:TextBox control any markup (node other than a text node) inside the textarea-- it only generates text inside it.
Therefore, you have to generate explicitly the textarea and the <xsl:value-of> on the server.
You can bind the Text property of TextBox control to this value in code-behind. That might work. BTW what is xsl and what you want to be printed.
XSL and ASP.NET aren't really friends.
You can try something like what you'll find here, but if you can - port your xsl to a resource file.
Related
I have used the Telerik RadEditor and the ExportToPdf method in C# but
when the PDF is downloaded it contains 0KB, but it contains data in the RadEditor content.
This is my code:
<telerik:RadEditor runat="server" ID="RadEditor1" SkinID="DefaultSetOfTools"
Height="515px" Visible="false" ContentFilters="DefaultFilters,PdfExportFilter">
<ExportSettings OpenInNewWindow="true" FileName="ErinLetter">
</ExportSettings>
<ImageManager ViewPaths="~/PDFbarcode" UploadPaths="~/PDFbarcode" DeletePaths="~/PDFbarcode"></ImageManager>
</telerik:RadEditor>
<br />
<div align="right">
<asp:Button ID="btnPdf" runat="server" CssClass="NFButton" Text="PDF" OnClick="btnPdf_Click" />
</div>
The content binds from the backend, for example:
<h2>Test RadEditor</h2>
but it returns 0KB.
Try setting the RadEditor's Visible property to true. I don't think export will work if it is false.
Also, compare your setup with the original here http://demos.telerik.com/aspnet-ajax/editor/examples/pdfexport/defaultcs.aspx and see what's the difference that breaks stuff.
Try to set the content inline in the declaration:
<telerik:RadEditor runat="server" ID="RadEditor1" SkinID="DefaultSetOfTools"
Height="515px" Visible="false" ContentFilters="DefaultFilters,PdfExportFilter">
<Content>
<h2>Test RadEditor</h2>
</Content>
<ExportSettings OpenInNewWindow="true" FileName="ErinLetter">
</ExportSettings>
<ImageManager ViewPaths="~/PDFbarcode" UploadPaths="~/PDFbarcode" DeletePaths="~/PDFbarcode"></ImageManager>
</telerik:RadEditor>
You can also hide the editor by wrapping it in a hidden
I was following this tutorial:
http://www.hongkiat.com/blog/css3-on-off-button/
I would like everything the same except I would like to change:
<section>
<a rel="external" href="#button" id="button"></a>
<span></span>
</section>
to:
<section>
<asp:Button CssClass="button" id="Button3" runat="server" OnClick="Button3_Click" Text=""\uf011;"" />
<span></span>
</section>
Because of simpler adding buttons and then programming them. Everything works OK, just when I click the button it doesn't become white and the red dot doesn't become green, I guess it's because in the tutorial is button used like a link, and if I add it with visual studio it's not a link, what could I do that i woul style the button like that even if I add it with visual studio.
If you want to have a hyperlink you should use LinkButton element. Button component shows a button element. LinkButton is rendered as a hyperlink with some extra properties.
<asp:LinkButton CssClass="button" id="Button3" runat="server" OnClick="Button3_Click" Text=""\uf011;"" />
Also you can try the following code in order to have code-behind capabilities for a stanrdard a tag.
<section>
<a rel="external" href="#button" id="button" runat="server"></a>
<span></span>
</section>
Another option is using HyperLink component
<section>
<asp:HyperLink Text="" rel="external" href="#button" id="button" runat="server"></asp:HyperLink>
<span></span>
</section>
You should pay attention to anchor's id attribute. I mean, The id attributes are prepended with MainContent_ if you have not set it to be shown only with the value you gave.
There are two options for this:
Change jQuery's selector from $('#button') to $('#MainContent_button')
Change .NET settings for showing your elements without prepending MainContent_ prefix.
My .aspx looks like the following:
<div id="valueIntroduction" type="text" class="labelarea" runat="server">
<input name="$labeluniversityid" type="text" id="labeluniversityid" style="color:#7D110C;border:0;background-color:#C0D5F2;width:100%" />
</div>
.cs File looks like:
if (results.Read())
{
labeluniversityid.value = results["TEXT_CONTENT"].ToString();
}
Exactly what am trying do is am getting the data from the database and displaying it in the valueIntroduction div. That is workiing fine. Now i added a text box with readonly mode. So that in my page if I press EDIT button, the value could be edited.
Use a TexBox component:
<asp:TextBox ID="labeluniversityid" runat="server" CssClass="yourcssclass"></asp:TextBox>
As for the styling:
.yourcssclass
{
color:#7D110C;
border:0;
background-color:#C0D5F2;
width:100%
}
Then, in your code behind you can easily use it like this:
labeluniversityid.Text = results["TEXT_CONTENT"].ToString();
Keep in mind that ASP.NET Controls are translated into common HTML tags, so you can wrap it and style it as you would with any other normal input of type text.
Also: type="text" is not valid for div
Try putting runat="server" attribute in <input id="labeluniversityid"> tag.
Or use a <asp:TextBox> control as areks suggests.
You need to add -
runat="server"
to your input field
Or, even better, use an
<asp:textBox ..>
i want to use MaxLength behaviour with multiline textbox, which become textarea on rendering.
i need to use Maxlength behaviour without using jquery or javascript.
Just set the maxlength attribute on the textarea, like so:
<textarea maxlength="5"></textarea>
Fiddle: http://jsfiddle.net/spaFS/
This will only work in HTML5 documents (and browsers that support it). In HTML4 and older browsers you can't achieve this without JavaScript.
Or for an ASP.NET TextBox, just do:
<asp:TextBox MaxLength="5" />
<asp:TextBox id="tb6" rows="5" MaxLength="20" TextMode="multiline"
runat="server" />
i have an asp.net webform. the users enter data into the textboxes and i do OnClick="SubmitData" with a button:
now i would like to use jquery and make my form look much better and i do not know if i can keep the asp.net controls or whether i have to convert to html controls.
question do i need to convert
<asp:TextBox ID="section_c_issue_error_identified_byTextBox" width="500" runat="server"
/>
to something like this:
<textarea name="comments" id="comments" rows="5" cols="60"></textarea>
and if so, how would i grab the user input from these new html textboxes?
can you tell me exactly how would i pass these values into my c# code?
You don't need to convert anything as it gets converted to html anyway on clientside.
There are few ways to grab the value of the text box such as,
If the following is my textbox,
<asp:TextBox ID="txtCountry" Width="500" runat="server" CssClass="countryText" />
I can use,
$('#<%= txtCountry.ClientID%>').val()
$('.countryText').val()
You don't need to convert anything, simply adding the property clientID the type static
ClientIDMode="Static"
That's warranted that the id asp component doesn't change the name of the id
<asp:TextBox ID="txtCountry" Width="500" runat="server" CssClass="countryText" ClientIDMode="Static" />
$('#txtCountry').val();
question do i need to convert
<asp:TextBox ID="section_c_issue_error_identified_byTextBox"
width="500" runat="server"
/>
to something like this:
<textarea name="comments" id="comments" rows="5"
cols="60">
Yes, you need to do that.
To capture input from those controls using JQuery, you need to do:
var elementValue = $('#elementid').val();
elementid is the id you assigned to the element in your markup. In your example above, it would be "comments".
elementValue will have the text entered in your text area.