PDA

View Full Version : سوال: اجرای یک صفحه aspx به عنوان یک صفحه واسط



behiunforgiven
پنج شنبه 28 بهمن 1389, 11:20 صبح
با سلام

میخواستم بدونم چطور میشه یک صفحه aspx رو فراخوانی کرد به طوری که توابعی که درونش به کار رفته به طور کامل اجرا بشه ولی نمایش داده نشه.

اگه اشتباه نکنم توی asp کلاسیک اگه اکشن یک فرم رو برابر اون صفحه قرار میدادیم میشد این کار رو کرد.

لازم به گفتنه که از کدهای جاوااسکریپت هم توی این صفحه استفاده شده.

یک سوال دیگه این که آیا میشه این صفحه رو با WebService پیاده سازی کرد؟

behiunforgiven
پنج شنبه 28 بهمن 1389, 15:11 عصر
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Services" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html >
<head id="Head1" runat="server">
<title>ASP.NET AJAX Web Services: Web Service Sample Page</title>

<script src="Tools/jquery-1.5.js" type="text/javascript"></script>
<script runat="server">

protected void Page_Load(object sender, EventArgs e)
{
RSS rss = new RSS();

if (Request.QueryString["NewsId"] != null)
{
int newsid;
Int32.TryParse(Request.QueryString["NewsId"], out newsid);
writeNewsTextUTF8(rss.getNewsLink(newsid));
}
}

public void writeNewsTextDefault(string text)
{
string input;
input = new System.IO.StreamReader(System.Net.WebRequest.Creat e(text).GetResponse().GetResponseStream(), System.Text.Encoding.Default).ReadToEnd();
Response.Write(input);
}

public void writeNewsTextUTF8(string text)
{
string input;
input = new System.IO.StreamReader(System.Net.WebRequest.Creat e(text).GetResponse().GetResponseStream(), System.Text.Encoding.UTF8).ReadToEnd();

Response.Write(input);
}

[WebMethod()]
public static void getFullText(string s,int newsid)
{

RSS rss = new RSS();
rss.getNewsText(s,newsid);

}

</script>

<script src="Tools/jquery.query-2.1.7.js" type="text/javascript"></script>
<script type="text/javascript">


$(document).ready(function() {

var newsfulltext;
newsfulltext = jQuery("#trNewsBody").text();
var queryString;
queryString = jQuery.query.get('NewsId');

$.ajax({
type: "POST",
url: "Temp.aspx/getFullText",
contentType: "application/json; charset=utf-8",
data: "{'s': '"+newsfulltext+"','newsid':'"+queryString+"'}",
dataType: "json",
success: AjaxSucceeded,
error: AjaxFailed
});

});

function AjaxSucceeded(result) {
alert("Succeed "+result.d);
}
function AjaxFailed(result) {
alert(result.status + ' ' + result.statusText);
}
</script>
</head>

<body>
<form id="form1" runat="server">

<div>


</div>

</form>
</body>
</html>




این کد صفحه ای هست که نوشتم. با استفاده از کد زیر صفحه رو فراخوانی میکنم ولی مثل این که گیر میکنه.



string uri = "http://localhost/RSSTest/temp.aspx?NewsId=" + id.ToString();
System.Net.WebRequest i = System.Net.WebRequest.Create(uri);
i.Method = "POST";
i.ContentLength = uri.Length;


کسی میدونه راه حل این که کدهای سمت کلاینت هم اجرا بشه بدون این که صفحه به صورت فیزیکی بالا بیاد چیه؟