Most of ASP.net programmers must have came across writing HTML control by using asp.net. It's not a problem. It can simply be done like this.
Response.Write("<input name='cmdTest' type='button' /> ");
But the problem comes while writing HTML controls with Javascript function attached and that function has arguments. The problem is due to not allowing of ASP.net to write ["] inside a string, as anything between bracket of Reponse.Write() shoud be purely string. This can be overcomed by just placing a single slash(\) before ("). The following example shows that.
Response.Write("<input name='cmdTest' type='button' onclick=\"fn_test('arg1','arg2')\" /> ");
0 comments:
Post a Comment