$(document).ready(
function () {
$.ajax({
type:
"POST",
contentType:
"application/json; charset=utf-8",
url:
"GetHTML.asmx/GetMarkup",
data:
"{}",
dataType:
"json",
success:
function (msg) {
var data = msg.hasOwnProperty("d") ? msg.d : msg;
//alert(data);
OnSucessCallBack(data);
},
error:
function (xhr, status, error) {
alert(xhr.statusText);
}
});
function OnSucessCallBack(data) {
//alert(data);
$(
"#myform").dform({
"action": "index.htm",
"method": "get",
"html": data
});
}
});
Data is as below:
[{ "name": "username", "id": "txt-username", "type": "text", "caption": "Username" }, { "name": "password", "id": "txt-password", "type": "password", "caption": "Password"}]
The data is rendered as text instead.
[
WebMethod]
[
ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetMarkup()//string formId
{
FormControl[] fcArr = new FormControl[2];
string markUp = "";
FormControl fc = new FormControl();
fc.name =
"username";
fc.id =
"txt-username";
fc.caption =
"Username";
fc.type =
"text";
fcArr[0] = fc;
fc =
new FormControl();
fc.name =
"password";
fc.id =
"txt-password";
fc.caption =
"Password";
fc.type =
"password";
fcArr[1] = fc;
markUp =
JsonConvert.SerializeObject(fcArr);
return markUp;
}