Can I access LINQPad's C# code from html elements? -


i have c# code encrypt/decrypt strings.

void main() {      string myparameters = "val=tksxhtj03uhasw4trfmlqg%3d%3d";     calc(myparameters).dump();  }  string calc(string str) {  using (webclient wc = new webclient())     {         //return webapi....     } } 

but know can create html via util.rawhtml , won't need change code every time.

so , added :

util.rawhtml("<input type='text' id='tbdata' /><br/><br/> <input type='button' id='btncalc' value='calc'/><br/> <br/> ").dump(); 

so looks :

enter image description here

but need run c# code button click ( html)

question:

is possible such thing linqpad ?

how can run calc() after clicking button? ( , read value textbox)

linqpad: 4.55.03 (anycpu)

this not direct answer, in absence of proper answer, here 2 alternative methods have used might help

the first using util.readline() in loop, eg

void main() {         {         calc(util.readline()).dump();     }     while (true); }  string calc(string str) {     using (system.net.webclient wc = new system.net.webclient())     {         return "from webapi....";            }    } 

the second use wpf elements rather hmtl, eg

void main() {     var lbl1 = new textblock{ text = "input value ", minwidth = 70 } ;     var lbl2 = new textblock{ text = "results     ", minwidth = 70  } ;      var tb  = new textbox{   minwidth = 500 } ;      var btn = new button { content = " calc " };     btn.horizontalalignment = system.windows.horizontalalignment.left;     btn.margin = new system.windows.thickness(5,1,1,1);     btn.maxwidth = 100;      var results = new textblock{ text = ""  } ;     btn.click += (sender, args) => { results.text = calc(tb.text); } ;      var panel1 = new dockpanel();     panel1.children.add(lbl1);     panel1.children.add(tb);     panel1.children.add(btn);      var panel2 = new dockpanel();     panel2.children.add(lbl2);     panel2.children.add(results);      panelmanager.stackwpfelement(panel1, "example");     panelmanager.stackwpfelement(panel2, "example"); } 

which should produce like

screenshot


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -