Sat 19 Jul 2008
Accessing Post Variables in C# ASP.Net
Posted by admin under Uncategorized |
I was writing dynamic form variables to the page and i needed to retrieve their values when updated. When i tried to access the variables with request.params[] collection i noticed that the keys were what id i had given them with a string appended to the start. I wrote this function to easiliy access the variables:-
public static string PostVal(string key) { string retval = ""; foreach (string s in HttpContext.Current.Request.Form.AllKeys) { string[] sr = s.Split('$'); if (sr[sr.Length - 1] == key) { retval = HttpContext.Current.Request.Form[s]; } } return retval; }
No Responses to “ Accessing Post Variables in C# ASP.Net ”
Comments:
Leave a Reply
You must be logged in to post a comment.