简体   繁体   中英

how to call javascript from dynamically created textbox in asp.net?

 // Assign Context-Menu to Control
    $(function () {
        var txt1 = "#" + "<%= **myCal**.ClientID %>";

        // Attach Context-Menu to Control
        $(txt1).contextMenu(ctxtMenu, { theme: 'vista' });
    });

Code behind

            TextBox lbl = new TextBox ();
            lbl.BorderColor = System.Drawing.Color.Black;
            lbl.BorderStyle = BorderStyle.Double;
            lbl.BackColor = System.Drawing.Color.BlanchedAlmond;
            lbl.Text = eventname + "<br/>" + dt + "" + dt1;
            e.Cell.Controls.Add(lbl);

I want to use a dynamically created asp.net TextBox in place of myCal

what should i do? please help

You could define a CSS class to this control:

lbl.CssClass = "menu";

and then use a class selector:

$(function () {
    // Attach Context-Menu to Control
    $('.menu').contextMenu(ctxtMenu, { theme: 'vista' });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM