How do i show a panel using linkbutton, both in the same repeateritem? - repeater

I have a repeater in which there's a link and a hidden panel (and some other stuff). I want this link (LinkButton) to show my panel. This is what i've got:
<asp:Repeater id="repeater1" runat="server">
<ItemTemplate>
....
<asp:LinkButton runat="server" ID="lnkTransits" Text="test" CommandName="Transits"/>
<asp:Panel CssClass="transits" id="pnlTransits" runat="server" Visible="False">
....
</asp:Panel>
</ItemTemplate>
</asp:Repeater>
Codebehind (binding the itemcommand in OnInit):
private void FlightList_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{
if (e.CommandName == "Transits")
{
var item = e.Item.DataItem;
//var panel = item.FindControl("pnl" + e.CommandName);
//panel.Visible = true;
}
}
}
DataItem is null and every single post says it should be so I've given that idea up. But what i'm hoping instead is that there might be some index value or some way to find "closest" or something that I can use. All i want is to make the panel visible (and hopefully with the same button be able to hide it as well perhaps using the commandargument "hide" "show").
If this is not the way to go to fix this then that's fine, what's the best way?
Thanks in advance

Related

Changes to the code - I do not see on the site

Got a question. For example, I change the code on the page
/catalog/view/theme/nextdef/template/extension/module/latest.twig
, or rather add a handler to the button:
<i class = "fa fa-heart" onclick = "window.dataLayer = window.dataLayer || [];
dataLayer.push ({'event': 'heart'}); "> </i> </button>
But when you click on this element, there are no changes. If you look at the page code, then it is also not updated. Although I write the cache and update the Disable cache inside the browser too, and still no changes ... I would be grateful if you help. thank
The problem was that the template editor had a history of this page. And there was no code. Apparently, he referred to her. I did not know that opencart prioritizes history compared to server files.

In C1 CMS How to create a list dynamically by getting input from user at the function property window?

Actually I am trying to create two controls one is drop down and another is List. Both are similar and easy for static values or values which are already stored somewhere.
But what I want is, I want the Power user to create or add / edit list items at the run time ( When he is inserting function to the page )
so similar concept to this : http://jsfiddle.net/DVbGY/1/
<div data-role="content">
<div id="items">
</div>
<input type="text" id="item" />
<input type="button" value="Add item to list" onclick="appendToList()"/>
<script>
var listCreated = false;
function appendToList(){
if(!listCreated){
$("#items").append("<ul id='list' data-role='listview' data-inset='true'></ul>");
listCreated = true;
$("#items").trigger("create");
}
var value = $("#item").val();
var listItem = "<li>" + value + "</li>";
$("#list").append(listItem);
}
</script>
but in the function property window.
Currently I am using comma separated list from user but its not viable solution as my next step is to add url as well with the input data from user so Lets say user wants to create a drop-down button and user is adding items and associating particular link to its items.
As you can see in above image i am getting data from user but instead of that text box i want to use above mentioned similar concept.
How can I make this possible ? or Is it possible in C1-CMS ? if yes please explain with Example in detail.
Thank you for your time and thanks reading this post.
It is not possible with the currently built in widgets.

Hide Tooltip for HTML5 validation defined in ASP.NET/MVC

When the input does not match the pattern specified by the pattern attribute, the browser displays "You must use this format:" in a tooltip on the field.
I cannot hide this tooltip message at all, can I? 'Cause even when I write
#Html.TextBoxFor(model => model.tbMyNumber, new { #pattern = "[0-9]{6,}", title="" })
it stills brings "You must use this format:" in the tooltip for this field.
How can I avoid this?
I don't think there is a way to do what you want without adding javascript. A simple alternative would be to verify with javascript (example below shown using jQuery) instead...
$('#myform').submit(function() {
if(!/^[0-9]{6,}$/.test($('#mytext').val())) {
return false;
}
});
This would prevent the form from submitting if the value doesn't match the pattern... without displaying the tooltip... just make sure you have an alternative so the user doesn't wonder why they can't submit the form.
I guess that is not what you expect as answer, but you can probably work the problem around with javascript
HTML:
* The string must be at least 6 digits
<br/>
<input type="text" onkeyup="isNumber(this)" onblur="lengthValidation(this)">
Javascript:
function isNumber(textbox)
{
textbox.value = textbox.value.replace(/[\D]+/, '');
}
function lengthValidation(textbox)
{
if (textbox.value.length < 6) {
document.getElementById("error").style.display = 'block';
} else {
document.getElementById("error").style.display = 'none';
}
}
Test it here: https://jsfiddle.net/mvxeous4/1/

How to prevent Sitecore rich text editor from adding span and style attributes

We have a very restricted rich text editor for our client. We only allow a handful of standard tags. We want all styling to be dictated by the CSS we've built for the site. They are not allowed to deviate.
We've removed most options form the toolbar and only having specific tags in the dropdown, but we recently added CSS to the editor so that the text in the editor is styled like it is on the page to make it easier for authors to visualize. Now under certain circumstances, it will insert span tags with inline styles like:
<h2><span style="font-family: Georgia, 'Times New Roman', serif; color: #232b37;">text</span></h2>
It seems to be pulling our CSS in. Is there a way to configure it to just not do this? Thanks.
No, you cannot change this behavior by configuration. What you could do is add an item:saving event handler, that removes any unwanted tags like these span tags whenever a content editor saves the item. It is not the nicest solution but at least it works. I often use it to clean out unwanted (empty) paragraph tags the rich text editor tends to add.
<event name="item:saving">
<handler type="ExampleProject.Events.RemoveUnwantedTags, ExampleProject" method="OnItemSaving" />
</event>
Removing empty P-tags is easy, but for your solution you could use a regex to replace any tags with an inline style attribute (which should be unique anyway).
Here's a mockup code template you could use to replace all rich text editor field values in an item for this event handler:
public class RemoveUnwantedTags
{
public void OnItemSaving(object sender, EventArgs args)
{
var item = Event.ExtractParameter(args, 0) as Item;
if (item == null)
{
return;
}
foreach (Field field in item.Fields)
{
if (!field.TypeKey.Equals("rich text", StringComparison.InvariantCultureIgnoreCase))
{
continue;
}
var content = field.Value;
if (!string.IsNullOrEmpty(content))
{
content = content.Trim();
// replace whatever you want over here
using (new SecurityDisabler())
{
item.Editing.BeginEdit();
field.Value = content;
item.Editing.EndEdit();
}
}
}
}
}
Of course it's tempting to make all sort of item:save pipelines because they just work. But don't forget about more specific pipelines that can actually hook into the moment after you click on the Accept button and the moment Sitecore put's the richtext in the field.
<!-- Transforms markup from rich text fields before the Rich Text Editor loads it. -->
<loadRichTextContent/>
<!-- Transforms markup from the Rich Text Editor before saving it as a rich text field value. -->
<saveRichTextContent/>
Both are pipelines that work great for this purpose.
An example implementation of this can be found at https://techmusingz.wordpress.com/2014/06/14/wrapping-rich-text-value-in-paragraph-tag-in-sitecore/
copy/paste from the website mentioned above:
public void Process(SaveRichTextContentArgs args)
{
if (!(args.Content.Trim().StartsWith("<p>") && args.Content.Trim().EndsWith("</p>")))
args.Content = "<p>" + args.Content + "</p>";
}
I personally don't like real string operations on the output so I would recommend handling the richtext content with HtmlAgilityPack (which Sitecore comes with) or use a XDocument.
Example by myself with HtmlAgilityPack that removes script and style elements:
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
// Strip output from all kinds of stuff
doc.DocumentNode.Descendants()
.Where(n => n.Name == "script" || n.Name == "style")
.ToList()
.ForEach(n => n.Remove());
An even better solution would be to parse and clean it up with a good and solid HtmlSanitizer.
https://github.com/mganss/HtmlSanitizer
Make sure you create some unittests to wrap the pipeline and test it to its extends.
Best Regards,
Alex van Wolferen

Using Updatepanel in sharepoint 2013 web part

We are facing problem related to updatepanel in sharepoint 2013. we have a sample webpart that includs a label and a button, we want to write somthing to label in click event of button without refreshing the whole page. Our sample code is as followed :
<asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<asp:Label ID="lbl" runat="server" Text="Loaded" Visible="true"></asp:Label>
<asp:Button ID="btn" runat="server" OnClick="btn_Click"/>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btn" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
protected void btn_Click(object sender, EventArgs e)
{
lbl.Text = "BUTTON CLICKED !";
lbl.Visible = true;
}
We have tried the solution mentioned on this link but could not achieve our goal.
Any solution for this problem along with sample code will be highly appreciated.
Thanks.
As I noticed the Content Search webpart and the update panel cannot work together on SharePoint 2013 for some reason. If I add my custom update panel webpart to stand alone page than working the updapanel well.
Have you tried to play with UpdateMode and ChildrenAsTriggers? Like this for example:
<asp:UpdatePanel id="UpdatePanel1" runat="server"
UpdateMode="Conditional" ChildrenAsTriggers="true" >