javascript - Request.QueryString is undefined -
i using following code logedinuser
login.aspx
, send chat.aspx
send frmforajaxcalls
return data db , fill on div in running time telling me in browser console request.querystring undefined
here login.aspx
code
protected void button3_click(object sender, eventargs e) { response.redirect("chat.aspx?lgn2="+textboxusername.text); }
and chat.aspx
javascript code
<script type="text/javascript" > var xmlhttp; function getdata() { xmlhttp = null; if (window.xmlhttprequest) { xmlhttp = new xmlhttprequest(); } else if (window.activexobject) { xmlhttp = new activexobject(); } string logedinuser = request.cookies["logedinuser"].value; var logedinuser = request.querystring["lgn2"]; xmlhttp.onreadystatechange = function () { if (xmlhttp.readystate == 4 || xmlhttp.status == 200) { document.getelementbyid("mydiv").innerhtml = xmlhttp.responsetext; } } xmlhttp.open("get", "frmforajaxcalls.aspx?lgn=" + logedinuser, true); xmlhttp.send(); }
then send frmforajaxcalls
return data return nothing on div request.querystring
undefined exption on browser console
protected void page_load(object sender, eventargs e) { string logedinuser = request.querystring["lgn2"].tostring(); stringbuilder html = new stringbuilder(); string result = string.empty; sqlconnection cnn = new sqlconnection(configurationmanager.connectionstrings["crconnection"].connectionstring); sqlcommand cmd = new sqlcommand("select messagenum , message , sendername ,date message reciverusername='" + logedinuser + "'", cnn); cnn.open(); sqldataadapter da = new sqldataadapter(cmd); datatable dt = new datatable(); da.fill(dt); html.append("<div id = xxx> "); html.append("<table border='1'>"); html.append("<tr>"); foreach (datacolumn col in dt.columns) { html.append("<th>"); html.append(col.columnname); html.append("</th>"); } html.append("</tr>"); foreach (datarow row in dt.rows) { html.append("<tr>"); foreach (datacolumn col in dt.columns) { html.append("<td>"); html.append(row[col.columnname]); html.append("</td>"); } html.append("</tr>"); } html.append("</table>"); html.append("</div>"); response.write(html); }
in paste chat.aspx
, you're calling lgn
instead of lgn2
... all? in situations this, first mission should add logging throughout process see falls apart, can pinpoint problem is.
Comments
Post a Comment