Telerik ASP.NET AJAX - Ajax Update Label with dynamic created Docks - ajax

i try to Update a simple Label on Close Event of dynamic created RadDock.
Works fine so far, Label gets the correct values but doesnt updates it.
RadDock dock = new RadDock();
dock.DockMode = DockMode.Docked;
dock.UniqueName = Guid.NewGuid().ToString();
dock.ID = string.Format("RadDock{0}", dock.UniqueName);
dock.Title = slide.slideName;
dock.Text = string.Format("Added at {0}", DateTime.Now);
dock.Width = Unit.Pixel(300);
dock.AutoPostBack = true;
dock.CommandsAutoPostBack = true;
dock.Command += new DockCommandEventHandler(dock_Command);
...
void dock_Command(object sender, DockCommandEventArgs e)
{
Status.Text = "Removed " + ((RadDock)sender).Title + " " + ((RadDock)sender).Text;
}
I tried to do this:
RadAjaxManager1.AjaxSettings.AddAjaxSetting(dock, Status, null);
while creating the docks, but on runtime i get a NullReference Excepetion.
On a Button registered with the RadAjaxManager it works to show the value
assigned by dock_command.
protected void Button1_Click(object sender, EventArgs e)
{
Status.Text = Status.Text;
}
UPDATE: The RadAjaxManager was created with integrated Wizzard of VS2008.
Can't select the Docks, because the are generated while runtime.
On Backend its included in AutoCompletion, so the NullReference has nothing to do
with the AjaxManager itself. Like i said, works fine with the Button.
<telerik:RadAjaxManager ID="RadAjaxManager1">
<telerik:AjaxSetting AjaxControlID="Button1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Label1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>

Questions was solved by Telerik Support here
http://www.telerik.com/community/forums/aspnet-ajax/docking/telerik-asp-net-ajax-ajax-update-label-with-dynamically-created-docks.aspx

Related

xamarin android (not forms) button tag

I need to pass some additional information with a button press. From what I could gather reading on the web I should use a button tag.
So far I have this
Button button = new Button(this);
button.Text = "Test Button";
button.SetBackgroundColor(Android.Graphics.Color.Black);
button.SetTextColor(Android.Graphics.Color.White);
button.Tag = "hello";
button.Click += ClickEvent;
And this is the handler:
public void ClickEvent(object sender, EventArgs e)
{
Android.Widget.Button button = (Android.Widget.Button)sender;
var test = button.Tag;
}
This works, but I need to be able to pass 3 ints of data. I have tried using an array but I have no idea how to read it in the handler as it comes back as a java.object.
Can anyone please push me in the right direction?

fire a popup when ApplicationBarMenuItem clicked

I need to fire a popup when ApplicationBarMenuItem clicked. but nothing happen when I click MenuItem. here is my code;
<shell:ApplicationBar.MenuItems>
<shell:ApplicationBarMenuItem Text="Go by date" Click="GoByDate_Click" />
</shell:ApplicationBar.MenuItems>
private void GoByDate_Click(object sender, EventArgs e)
{
Popup popup = new Popup();
popup.Height = 480;
popup.Width = 480;
popup.VerticalOffset = 100;
DatePopupControl datePopup = new DatePopupControl(); // just a user control comes when add new
popup.Child = datePopup;
popup.IsOpen = true;
}
Something is wrong with your DatePopupControl, because your code worked fine for my own test control. Can you provide DatePopupControl source code?
Alright, let me try to guess. My first theory is: there is nothing to show in this popup.
For example, if you add a userControl, which has only Grid tag inside without anything, you will see in the editor in Visual Studio, but it won't be visible as a popup child. But if you add a single textblock, it will be.

Hyperlink button website

I need to put button that after click moves user to website. Can someone tell me what should I put into vb and in xaml?
<HyperlinkButton Content="Click here to learn about Silverlight" NavigateUri="http://www.silverlight.net" TargetName="_blank" />
You can do it also in C#
private void HyperlinkButton_Click(object sender, System.Windows.RoutedEventArgs e)
{
var task = new Microsoft.Phone.Tasks.WebBrowserTask
{
URL = "http://siteaddress.com",
};
task.Show();
}

Telerik RadGrid ExportToPDF() or ExportToExcel() not working

I have a simple class inheriting RadGrid. I am adding a button to the RadGrid and a Click Event handler to that button. The button is correctly added in the required position and the click event handler is firing, but radGrid.ExportToExcel() is not doing anything. In fact, upon click and when page posts back, the button disappears. Why is this happening?
I tried to add the button control to the Page.Form control collection, but still nothing happens.
[ToolboxData("<{0}:RadGridDp runat=server></{0}:RadGridDp>")]
public class RadGridDP : RadGrid
{
public RadGridDP()
{
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Button btnExport = new Button();
btnExport.ID = "Export";
btnExport.Text = "Export";
btnExport.Click += new EventHandler(btnExport_Click);
btnExport.CommandArgument = this.ID;
this.MasterTableView.Controls.Add(btnExport);
}
void btnExport_Click(object sender, EventArgs e)
{
Button btnExport = (Button)sender;
string RadGridId = btnExport.CommandArgument.ToString();
RadGridDP radGrid = (RadGridDP)this.Parent.Parent.FindControl(RadGridId);
radGrid.ExportSettings.IgnorePaging = true;
radGrid.ExportSettings.OpenInNewWindow = true;
radGrid.ExportSettings.ExportOnlyData = true;
radGrid.MasterTableView.ExportToExcel();
}
}
When I do same thing in a UserControl and use that UserControl on any page, it works fine. What's the difference?
I found out the solution. Whenever RadGrid Loads, it calls various events in this fashion:
1. Page OnLoad
m. RadGrid OnLoad
x. NeedDataSource
and upon click of the button (added in the manner above), events are called in this fashion
1. Page_OnLoad
m. RadGrid OnLoad
n. btnExport_Click
x. NeedDataSource
(as for strange serial numbers, these events may have other events in between, but the order of occurance is correct)
so, entire Grid is rebound with the data, and hence command to exportPdf is flushed. So nothing happens.
Interestingly, there's no need of adding one extra button, telerik provides its own buttons to do so. which can be customized as well(by implementing ITemplate). This is how am generating Reports now(though not specific to the original question):
[ToolboxData("<{0}:RadGridDP runat=server></{0}:RadGridDP>")]
public class RadGridDP : RadGrid
{
//custom logic
public RadGridDP()
{
this.ItemCreated += new GridItemEventHandler(RadGrid_ItemCreated);
this.Load += new EventHandler(RadGridDP_Load);
this.ItemCommand += new GridCommandEventHandler(RadGrid_ItemCommand);
this.PdfExporting += new OnGridPdfExportingEventHandler(RadGridDP_PdfExporting);
this.GridExporting += new OnGridExportingEventHandler(RadGridDP_GridExporting);
this.ExportSettings.ExportOnlyData = true;
this.ExportSettings.IgnorePaging = true;
// this.ExportSettings.OpenInNewWindow = true;
DoPdfFormatting();
DoExcelFormatting();
}
protected void RadGridDP_PdfExporting(object sender, GridPdfExportingArgs e)
{
e.RawHTML = e.RawHTML.Replace("border=\"1\"", "").Replace("style=\"", "style=\" border:0.5px Solid black; ")
.Replace("<thead>", String.Format("<thead>{0}", TableHeader)).Replace("</tbody>", String.Format("{0}</tbody>", TableFooter));
}
protected void RadGridDP_GridExporting(object sender, GridExportingArgs e)
{
e.ExportOutput = e.ExportOutput.Replace("<thead>", String.Format("<thead>{0}", TableHeader))
.Replace("</tbody>", String.Format("{0}</tbody>", TableFooter));
}
}
so basically i had to handle PdfExporting(for Pdf) and GridExporting(for excel)..
I had to handle Load, ItemCommand and ItemCreated as well. While the former one was required for some conditional logic, later two were required for formatting of the PDF document

Sharepoint 2010 - Problem with event handlers for dynamically created controls

In a WebPart using Sharepoint 2010, I´ve got a problem when creating dynamically a LinkButton because his event isn´t fired.
My code is:
Default.aspx
<asp:TextBox ID="formAccountCode" runat="server" MaxLength="8" Columns="8"></asp:TextBox>
<asp:Table ID="idTabela" runat="server" Width="100%" BorderWidth="1px" GridLines="Both"></asp:Table>
<asp:Button ID="btPesquisar" runat="server" onclick="btPesquisar_Click" Text="Pesquisar" />
Default.aspx.cs
protected void btPesquisar_Click(object sender, EventArgs e)
{
LinkButton lkButton = new LinkButton();
lkButton.Text = "Teste Tabela";
lkButton.ID = "link1";
lkButton.Attributes.Add("runat", "server");
lkButton.CommandArgument = "Codigo 1";
lkButton.Command += test;
TableRow tr;
TableCell td1;
td1 = new TableCell();
td1.Controls.Add(lkButton);
tr = new TableRow();
tr.Cells.Add(td1);
idTabela.Rows.Add(tr);
idTabela.DataBind();
}
protected void test(object sender, EventArgs e)
{
formAccountCode.Text = "HI"; // just for test
}
The idea is return a select from DB and create a result with linkbutton to each record returned.
These LinkButtons will be created after an action from the user, because this, it can´t be created in OnInit.
They will connect with another web part.
please move the code for dynamically created button and event handler in CreateChildControls() and call the EnsureChildControls() in Onload
For example:
protected override void CreateChildControls()
{
base.CreateChildControls();
// Create our drop down list, but don't populate it yet
_dropDownList = new DropDownList();
this.Controls.Add(_dropDownList);
}

Resources