PDA

View Full Version : مشکل با Web Service گوگل



night11
پنج شنبه 16 شهریور 1385, 10:01 صبح
من یه تاپیک دیدم که آقای راد توی اون استفاده از وب سرویس گوگل رو گذاشته بودن البته با vb بود من با #C نوشتم اما خطا داره لطفا راهنمایی کنید . البته با vb هیچ مشکلی نداشت .

اینم لینک تاپیک
http://barnamenevis.org/forum/showthread.php?t=49881&highlight=web+service

در مورد این ViewState هم اگه توضیح بدین ممنون میشم

این کد سی شارپ


const int PAGE_SIZE = 5;

void DisplaySearchResult()
{

SearchResults.Visible = true;
localhost.GoogleSearchService Search = new localhost.GoogleSearchService();
localhost.GoogleSearchResult result;
result = Search.doGoogleSearch("code", SearchTerms.Text ,
(int)ViewState["startIndex"],PAGE_SIZE, true, "", true, "", "", "");
dlResults.DataSource = result.resultElements;
dlResults.DataBind();
lblSearchResults.Text = "Viewing records " + String.Format("{0:#,###}", (int)ViewState["startIndex"] + 1) + " _ " +
String.Format("{0:#,###}", (int)ViewState["startIndex"] +
PAGE_SIZE) + " of about " +
String.Format("{0:#,###}",result.estimatedTotalResultsCount) +
" . Search took " +
String.Format("{0:#,###}",result.searchTime) + " sec.";
btnPrev.Enabled = (int)ViewState["startIndex"] > 0 ;
}


این قسمت ایراد می گیره



protected void execSearch_Click(object sender, EventArgs e)
{
ViewState["startIndex"] = 0;
DisplaySearchResult();
}

protected void btnNext_Click(object sender, EventArgs e)
{
ViewState["startIndex"] += PAGE_SIZE;
DisplaySearchResult();
}

protected void btnPrev_Click(object sender, EventArgs e)
{
ViewState["startIndex"] -= PAGE_SIZE;
DisplaySearchResult();
}


این کد vb



Const PAGE_SIZE As Integer = 5

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

End Sub

Sub DisplaySearchResults()
SearchResults.Visible = True
Dim search As localhost.GoogleSearchService = New localhost.GoogleSearchService()
Dim result As localhost.GoogleSearchResult
result = search.doGoogleSearch("code", SearchTerms.Text, _
ViewState("startIndex"), PAGE_SIZE, True, "", True, "", "", "")
dlResults.DataSource = result.resultElements
dlResults.DataBind()
lblSearchResults.Text = "Viewing records " + String.Format("{0:#,###}", ViewState("startIndex") + 1) & " _ " & _
String.Format("{0:#,###}", ViewState("startIndex") & _
PAGE_SIZE) + " of about " & _
String.Format("{0:#,###}", result.estimatedTotalResultsCount) & _
" . Search took " & _
String.Format("{0:#,###}", result.searchTime) & " sec."
LinkButton1.Enabled = (ViewState("startIndex") > 0)
End Sub




Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
ViewState("startIndex") = 0
DisplaySearchResults()
End Sub

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
ViewState("startIndex") -= PAGE_SIZE
DisplaySearchResults()
End Sub

Protected Sub LinkButton2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
ViewState("startIndex") += PAGE_SIZE
DisplaySearchResults()
End Sub

night11
پنج شنبه 23 شهریور 1385, 18:43 عصر
برای تبدیل این کد وی بی به سی شارپ کسی کمک نمی کنه ؟