[SOLVED] Id control in Javascript

Answered Closed
0
0

Hi Wisej,

I am using this code in javascript:

Wisej.Core.getComponent(“Button1”)

OR

this.Button1.Handle

OR

App.Window1.Button1.Handle

They all get null.

How to get id control when using javascript in wisej framework?

Thank you.

  • You must to post comments
Great Answer
0
0
document.getElementById() returns the dom element used by the widget to render itself. If you want to use the element you can do this:
var dom = document.getElementById(widget.getId());
or
var dom = widget.getContentElement().getDomElement();
Keep in mind that the widget (javascript object) may override your changes to the dom. Also our widgets don’t update the dom directly, they all have an “shadow” dom element that is flushed in sync with the browser (aka: fast dom). That’s why there is the getContentElement() before getDomElement(). If you want to change the style, you can also use
widget.getContentElement().setStyle(name, value);
or
widget.getContentElement().setStyle(map);
  • You must to post comments
Great Answer
0
0

App.Window1.button1 is already the widget: i.e. App.Window1.button1.hide(), App.Window1.button1.show(), App.Window1.button1.execute(), …

You can retrieve a widget using the unique id like this: widget(“id_22”);

When calling from the server, simply use “this”: i.e. this.button1.Eval(“this.hide()”), or this.button1.Call(“hide”). You can also pass widgets as parameters from the server, Wisej takes care of marshalling the reference to/from the server/client. i.e.: this.Call(“doSomething”, this.button1).

From javascript on the client you can also call [WebMethod] methods directly and pass maps and even other widgets, again Wisej marshals the reference:

App.Window1.SomeServerMethod(App.Window1.button1);

=>

[WebMethod]

public void SomeServerMethod(Button button) {}

If you have a specific requirement, please send sample code to show what you need to do.

 

HTH

  • You must to post comments
0
0

Hi Luca ITG,

This is link: https://www.aspsnippets.com/Articles/Print-Crystal-Report-on-Client-Side-on-Button-Click-using-JavaScript-in-ASPNet.aspx

I want to do using iframe to quick print crystalReportViewer:

<script type=”text/javascript”>
function Print() {
    var dvReport = document.getElementById(“dvReport”);
    var frame1 = dvReport.getElementsByTagName(“iframe”)[0];
    if (navigator.appName.indexOf(“Internet Explorer”) != -1) {
        frame1.name = frame1.id;
        window.frames[frame1.id].focus();
        window.frames[frame1.id].print();
    }
    else {
        var frameDoc = frame1.contentWindow ? frame1.contentWindow : frame1.contentDocument.document ? frame1.contentDocument.document : frame1.contentDocument;
        frameDoc.print();
    }
}
</script>
Do you have demo using this code to quick print crystalReportViewer with  wisej framework?

Thank you so much.

  • You must to post comments
0
0
Hi Luca ITG,
When using document.getElementById(id). I want to get id of control in javascript for document.getElementById function.
How to get id of control when using ClientEvents of control?
Thank you so much.
  • You must to post comments
Showing 4 results