开发者

Get values of js generated controls, from server side

Let me explain the case;

On the asp.net page, i have a repeater which generates <tr>s and <td>s.

On clientside, i have a js function which adds or开发者_开发问答 deletes rows into that repeater-generated-table.

The problem is, in this function, i dont only generate a simple row, a textbox (which i have to get its value on server side) is generated too.

Is there any way to get value of client-generated controls ?


You can use AJAX to make the connection between the client side and the server side. You can try THIS or read THIS article.


At first glance, I would say you can write an AJAX request to send to the server the content of your textbox and act accordingly.

Beware though, that it can never interact with the server during a page generation cycle.


For who is interested in this topic, Request.Form solved my problem.

Here is the code

The pattern of the name propery is for example: name="txtReturnCause_56"

Dictionary<int, string> ReturnCauses = new Dictionary<int, string>();

            foreach (var key in Request.Form.AllKeys)
                if (key.StartsWith("txtReturnCause"))
                {
                    int _key = key.Split(char.Parse("_"))[1].ToInt();
                    string value = Request.Form[key];
                    ReturnCauses.Add(_key, value);
                }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜