Maybe I'm having a brain fart or something because it seems like this should be pretty simple but how do you update a User Control from another User Control via Ajax?
I have an ASPX page with two user controls and when I trigger a server-side event on one, I want to refresh a grid on the other so it'll update it's data.
I'm using Telerik controls if that helps. Checkbox event on the first User Control causes the RadGrid in the second User Control to Rebind() and I have RadAjaxManager in the ASPX page and RadAjaxManagerProxy in the two User Controls.
First for me Page.DataBind() doesn't work for me.
I declared in UserControl
// Declare a delegate
public delegate void save_CommandEventHandler ();
//Event
save_CommandEventHandler SaveViewChanged public event;
// I run SaveViewChanged() from a click_button but it can run from anywhere
protected void save_Click (object sender, EventArgs e)
{
UpdateDataInDatabase();
SaveViewChanged ();
}
In page.aspx.cs code
protected override void OnInit (EventArgs e)
{
base.OnInit (e);
// UserControle1 is the Id of your UserControl declared in Aspx Page
UserControle1.SaveViewChanged + =
New UserControle.save_CommandEventHandler
(Save_CommandEventHandler);
}
private void save_CommandEventHandler () {
// Reload the gridView gvExpence to see the change operated in the user control
gvExpence.DataSource =DataAcces.getAllCompanyExpence ();
gvExpence.DataBind ();
// update user control 2
usercontrol2.updateView();
}
An async callback will update the control that caused the postback and also any parent controls of its update panel. If your datagrid is not being updated in the browser after an event it would suggest its update method is not being called
Try calling the .update method of the datagrids updatepanel in the checkbox event
You could try using the ajaxRequest or ajaxRequestWithTarget client-side methods of the AjaxManager to initiate an ajax call. More info about these methods can be found on the Telerik's online documentation: http://www.telerik.com/help/aspnet-ajax/ajxclientsideapi.html
Related
I am trying to create a custom control for webview, i am trying to get a checkbox inside a webview Reason :- we have a bunch of text to be displayed and unless the user reaches the end of the scroll he cannot move to the next page and at the end of the scroll there is a checkbox where user has to check the the checkbox and then he can process. here i have tried putting the checkbox and webview inside the stacklayout but the issue is webview have its own scroll bar and and stacklayout scroll bar does not work when a user try to scroll as the webview scroller scrolls out also when i try to close the Webview Page with back button the webview gets close and not the page
i am not sure what approach should i apply here.
i am getting my html data from my webapi.
anyone with some solution would be appreciable
here is my custom renderer which i have wrote but the piece missing here is how can i add another xamarin control inside this
public class CustomPdfViewRenderer : WebViewRenderer
{
public CustomPdfViewRenderer(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<WebView> e)
{
base.OnElementChanged(e);
if (Control != null)
{
Control.Settings.BuiltInZoomControls = true;
Control.Settings.DisplayZoomControls = false;
Control.Settings.LoadWithOverviewMode = true;
Control.Settings.UseWideViewPort = true;
}
}
}
You can try the following approach:
Add checkbox to HTML
When the user check checkbox call some JavaScript function
When JavaScript function is called, call C# function (Xamarin) which will enable the user to process to the next page (or some other Xamarin side stuff)
Here is how you can call C# function from JavaScript :HybridWebView
I have a very simple outlook form region. It is configured as a separate item, and, it is set to appear whenever a we try to compose a new appointment item. (Meeting request).
Once I click the button above, it should populate the sender and go back to the main appointment page. The code to do that is:
private void button1_Click(object sender, EventArgs e)
{
item.RequiredAttendees = "John.Doe#contoso.com";
var exp = item.Application.ActiveInspector();
if (exp == null) Debug.Print("NULL");
else exp.ShowFormPage("Appointment");
}
But this doesn't do anything. What is the correct way of doing this?
Use the SetCurrentFormPage method of the Inspector class to display the specified form page or form region in the inspector.
As a workaround you may try to call the Appointment button programmatically. Use the ExecuteMso method of the CommandBars class to execute the control identified by the idMso parameter. See Office 2013 Help Files: Office Fluent User Interface Control Identifiers for the actual idMso values.
Is it possible to detect the DOM elements under a spot the user taps on a website using the WP7 WebBrowser control? I would like to let the user identify certain sections of the rendered page.
Yes. This code works pretty well for me:
private void button1_Click(object sender, RoutedEventArgs e)
{
// first define a new function which serves as click handler
webBrowser1.InvokeScript("eval", "this.newfunc_eventHandler = function(e) { window.external.notify(e.srcElement.tagName); }");
// attach function to body
webBrowser1.InvokeScript("eval", "document.body.addEventListener('click', newfunc_eventHandler, false);");
}
private void webBrowser1_ScriptNotify(object sender, NotifyEventArgs e)
{
// this should be called every time you tap an element; the value should be its tag name
Debug.WriteLine(e.Value);
}
It goes along Justin's answer (who beat me while coding). It first defines a click handler which then is attached to the page's body (all via InvokeScript). Every time you tap an element ScriptNotify should be called on the WebBrowser reporting the tapped element's tag name.
Make sure you have set IsScriptEnabled true for your browser control.
I'm guessing you'd have to build something off of the ScriptNotify Event.
At that point, you would register a JavaScript Event handler as usual but that event handler would, in turn, call window.external.notify("someMessageToHandle");. You would then have to route the calls appropriately.
If you don't have the ability to add the JavaScript event handlers directly on the page, you could instead add them using WebBrowserControl.InvokeScript.
In normal version of silverlight you can create an event handler by registering it by EventManager. Windows Phone 7 hasn't got that class.
My question is: How to create an event, which will be handled by the parent panels.
My scenario: I've created a custom class with some textbox in it. Foreach I've added my custom behavior, which raises when textblock is clicked. Behavior works like: "When this Textblock in custom control is clicked, please raise a custom event with my custom args (i want to pass them to the Custom Control itself (for example to specify to which VisualState change it)."
Can you help me how to handle my problem?
Could you provide sample code of what you are trying to do? it seems you want to create an event for when the TextBlock is clicked.
Add an event handler to the textblock:
public Event EventHandler<RoutedEventsArgs> TextClicked;
// Fire the event
private void OnTextClicked(object sender, RoutedEventArgs e)
{
if (TextClicked != null)
{
TextClicked(sender, e);
}
}
TextBlock.Click =+ OnTextBlockClicked;
private void OnTextBlockClicked(object sender, RoutedEventArgs e)
{
// Raise event
OnTextClicked(sender, e);
}
Something along those lines I think.
Have the below code to switch requests from ‘http’ to ‘https’ when user clicks on a button. This is to protect user/password info before it is sent to the server. In the server, should call the code behind associated to the button but is not doing it. On pages that are NOT under Umbraco this code works fine.
Control:
<asp:ImageButton ID="btnLogin" runat="server" OnClick="btnLogin_Click" ... />
Code behind:
protected void Page_Load(object sender, EventArgs e)
{
PostBackOptions pbOptions = new PostBackOptions(btnLogin);
pbOptions.ActionUrl = Request.Url.ToString().Replace("http://", "https://");
btnLogin.Attributes.Add("onclick", "this.disabled = true; + Page.ClientScript.GetPostBackEventReference(pbOptions) + ";");
}
protected void btnLogin_Click(object sender, ImageClickEventArgs e)
{
want to execute that code
}
If put this code in an Umbraco page, when click on the login button the request changes to ‘https’, page is post to the server but the btnLogin_Click event is NOT called.
Is there something need to change to make this work in Umbraco? Does anybody know a solution / work around to make ‘btnLogin_Click’ to be executed? Or any idea where I can look to find the problem?
Thanks
Have you tried adding in your Page_Load:
btnLogin_Click += new ImageClickEventHandler(btnLogin_Click);
You may need to add this, as unless you have AutoEventWireup="true" specified in your usercontrol/masterpage declaration, it won't be automatically fired on postback.
HTH,
Benjamin