|
If that's the whole code for service, I don't see any problems so I'd guess that the problem is at calling side. How do you invoke the webmethod and discover the service?
|
|
|
|
|
Further investigation and I have to apologise, it was indeed nothing to do with those methods.
In the constructor I add some settings to a static dictionary and when the web service is called again the constructor is called again to add to the static dictionary.
I'm still a little unsure how web services work now then, is it the case then that all static classes remain between sessions and only the web service class themselves that are recreated each time a web service is called or something?
Is there anywhere that explains exactly what is and isn't created when a web service method is invoked and what is/isn't destroyed afterwards?
|
|
|
|
|
The basic idea is that app domains are separated, they cannot have common data. Inside an app domain you can share the data.
When you call a web service the first time, it's compiled and then executed inside an IIS process. After that the process dies if it's no longer called in a decent amount of time (which can be configured). However, if the process exists when the second call comes the worker thread from the process is taken to serve the call. Without seeing the code, this could be the reason why the dictionary is already filled.
|
|
|
|
|
Huston...
Ok, I commited to developing an application wrapper and, as usual, after delving into the nitty gritty, found out that the first guess wasn't quite right.
I have an intranet site which runs various reports, say 10 asp.net 1.1 pages.
I was asked to write a wrapper application around these reports, to provide default values to them, run them each in sequence and capture the output. The output is then sent via email to the report recipients.
ok, that's not too bad.
here's where my troubles start.
1. the site uses forms authentication;
so when a request is received for a page, i get redirected to a login page.
I've got to then parse the login page for viewstate variable, and manually submit the username and password back to the server to get a security token.
2. The reports use an asynchronous loading pattern similar to this site http://msdn.microsoft.com/en-us/magazine/cc163553.aspx[^]
where the initial page redirects the response to a wait page. the wait page then polls the original page continuously until the page has completed it's execution.
I've been scratching my head for about a week now.
I'd really appreciate any help on this.
Other than rewriting the reports one by one myself, I can't see what I can do.
Maybe I could manage step 1, with the login stuff, but I don't have a clue with issue #2
.
|
|
|
|
|
Is it possible to edit slightly the first application and provide a web service method to 'authenticate' you to the site, or something similar.
|
|
|
|
|
Hi,
I think I can get the authentication thing, it's just a bit messy, scraping response strings,
the real issue is in how to handle the async loading
|
|
|
|
|
Hi,
I want to access a public function declared in a content page from the master page.
I have a master page and a few content pages that have the same master page.On click of a button in the master page I want to call a function from the content page.All my content pages have the function with the same name...but they have different functionality based on the page.
I tried and I was successfull in accessing the content page controls properties from master page using below code.
Me.ContentPlaceHolder1.Page.FindControl("Button").Visible = False
Please let me know how to call a Content page function named "ValidateContent" from the master page.
Thanks in Advance.
modified on Thursday, December 4, 2008 9:48 AM
|
|
|
|
|
I think the best way to do this would be to create in interface which defines the function you want to call that your web forms implement:
<br />
public interface IContent<br />
{<br />
string ValidateContent();<br />
}<br />
then from your master page you can cast the child page as an IContent interface as return the appropriate value:
<br />
IContent child = (IContent)this.Page;<br />
Response.Write(child.ReturnValue());<br />
It definitely isn't definatley
|
|
|
|
|
How to get the IContent on the master page? (Its not Defined)
Dim child As IContent = DirectCast(Me.Page, IContent)
Thanks
|
|
|
|
|
You'll need to declare the IContent interface within your website (the code I supplied was in C#). Create a file called IContent.vb (replacing 'IContent' with whatever name you feel is appropriate for your useage) and add the following code:
<br />
Public Interface IContent<br />
Function ValidateControl() As String<br />
End Interface<br />
your web form must then implement the Interface using the 'Implements' keyword:
<br />
Public Class MyWebForm Implements IContent<br />
Public Function ValidateControl<br />
'code goes here<br />
End Function<br />
End Class<br />
The code you've provided will (as far as I know - I'm not from a VB.NET background) allow you to access the IContent interface correctly.
It definitely isn't definatley
|
|
|
|
|
Thanks For your reply Please take look at the below and let me know where I am going wrong
Step 1:
I created a Icontent.Vb file in appcode
Code:
Imports Microsoft.VisualBasic
Public Class IContent
Public Interface IContent
Function ValidateControl() As String
End Interface
End Class
Step 2:
I have Content Page (ASPX.VB Code behind) where I have the ValidateControl Function
Code:
Imports System.Web
Partial Class MyCodeBehind
Inherits System.Web.UI.Page
Implements IContent.IContent (Give Error Says MyCodeBehind must implement 'Function ValidateControl() As String' for interface 'IContent.IContent')
Public Function ValidateControl As String
Dim A As String = "Yes"
Return A
End Function
End Class
Step 3:
In my Master page where I want call the ValidateControl Function
Code:
Partial Class MyMaster
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim child As IContent.IContent = DirectCast(???, Content) (???)
child.ValidateControl()
End Sub
End Class
Thanks
Arif
modified on Thursday, December 4, 2008 12:20 PM
|
|
|
|
|
In VB.NET you need to specify the function that implements the interface so instead of
<br />
Public Function ValidateControl As String<br />
Dim A As String = "Yes"<br />
Return A<br />
End Function<br />
you need to decorate the method signature as:
<br />
Public Function ValidateControl As String Implements IContent.IContent.ValidateControl<br />
Dim A As String = "Yes"<br />
Return A<br />
End Function<br />
The code in the final section is almost right - it should look like this:
<br />
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)<br />
Dim child As IContent.IContent<br />
child = DirectCast(Me.Page, IContent.IContent)<br />
child.ValidateControl()<br />
End Sub<br />
Obviously you'll want to change the return type of 'ValidateControl()', probably so that it returns a boolean rather than a string. You can do this by changing the signature specified by the interface and then making the appropriate function change so that a true or false value is returned depending on whether the control was successfully validated.
Interfaces are very important in OO design so I'd recommend having a look around the internet (starting with CodeProject!) for some decent articles.
Hope that helps
It definitely isn't definatley
modified on Thursday, December 4, 2008 12:55 PM
|
|
|
|
|
Works!!
Thank you very much for your kind help.
Sure I will try to improve my OO design skills.
|
|
|
|
|
Hi this is Rajesh,
I am developing Fillable pdf form document management system using Asp.net. In that am displaying the pdf forms to Users by using IFRAME control like below...
<iframe src="fw9.pdf" width="970px" height="435px"></iframe>
And my question is, how to get or save the filled PDF form to the server.
is there anyway or any controls to do the above work... Let me know...
Thanks
Regards
C.Rajesh B.E
|
|
|
|
|
i have downloaded ur code of gridview with check boxes ...there u r not provided the functions....RetrieveItems()and DeleteRows() ...so i have written on my own ...i am getting 2 errors:
1.---->'gridview.RetrieveItems()': not all code paths return a value
2.----> No overload for method 'DeleteRows' takes '1' arguments
so plz go through the code and help me out its urgent....
thanks in advance.....
Here's the aspx.cs code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Data.SqlClient;
public partial class gridview : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
// Include the JavaScript functions during Form_Load() itself.
CheckBoxJSFunctions();
if (!Page.IsPostBack)
{
PopulateGrid();
}
}
private static DataTable RetrieveItems() //Error No:1
{
//Create a connection to the SQL Server; modify the connection string for your environment
//SqlConnection MyConnection = new SqlConnection ("server=(local);database=pubs;Trusted_Connection=yes");
SqlConnection MyConnection = new SqlConnection("server=(local);database=pubs;UID=myUser;PWD=myPassword;");
// Create a Command object, and then set the connection.
// The following SQL statements check whether a GetAuthorsByLastName
// stored procedure already exists.
SqlCommand MyCommand = new SqlCommand("select * from sysobjects where id = object_id(N'GetPosts')" +
" and OBJECTPROPERTY(id, N'IsProcedure') = 1", MyConnection);
// Set the command type that you will run.
MyCommand.CommandType = CommandType.Text;
// Open the connection.
MyCommand.Connection.Open();
// Run the SQL statement, and then get the returned rows to the DataReader.
SqlDataReader MyDataReader = MyCommand.ExecuteReader();
// If any rows are returned, the stored procedure that you are trying
// to create already exists. Therefore, try to create the stored procedure
// only if it does not exist.
if(!MyDataReader.Read())
{
MyCommand.CommandText = "create procedure GetPosts" +
" (@date varchar(40),@title varchar(50),(@author varchar(40),@categories varchar(50),(@tags varchar(40),@comments varchar(50)(@status varchar(40), select * from Posts where" +
" Date like @date,PTittle like @title,Author like @author,Category like @categories,Tags like @tags,TotalComments like comments,PStatus like @status; select @RowCount=@@ROWCOUNT";
MyDataReader.Close();
MyCommand.ExecuteNonQuery();
}
else
{
MyDataReader.Close();
}
MyCommand.Dispose(); //Dispose of the Command object.
MyConnection.Close(); //Close the connection.
}
private void PopulateGrid()
{
// RetrieveItems() is a user defined function that calls the stored proc to retrieve data from the database.
DataTable dtItems = RetrieveItems();
GridView1.DataSource = dtItems;
GridView1.DataBind();
}
private void CheckBoxJSFunctions()
{
StringBuilder strScript = new StringBuilder();
strScript.Append("<script language=JavaScript>");
strScript.Append("function CheckAll(checkAllBox)");
strScript.Append("{");
strScript.Append("var frm = document.form1;");
strScript.Append("var ChkState = checkAllBox.checked;");
strScript.Append("for(i=0; i<frm.length; i++)");
strScript.Append("{");
strScript.Append("e=frm.elements[i];");
strScript.Append("if(e.type == 'checkbox' && e.name.indexOf('Id') != -1)");
strScript.Append("e.checked = ChkState ;");
strScript.Append("}");
strScript.Append("}");
strScript.Append("</script>");
if (!this.IsClientScriptBlockRegistered("clientScriptCheckAll"))
this.RegisterClientScriptBlock("clientScriptCheckAll", strScript.ToString());
//------------------------------------------------------------------------------
strScript.Append("<script language=JavaScript>");
strScript.Append("function CheckChanged()");
strScript.Append("{");
strScript.Append("var frm = document.form1;");
strScript.Append("var boolAllChecked;");
strScript.Append("boolAllChecked=true;");
strScript.Append("for(i=0; i<frm.length; i++)");
strScript.Append("{");
strScript.Append("e = frm.elements[i];");
strScript.Append("if (e.type =='checkbox' && e.name.indexOf('Id') != -1 )");
strScript.Append("if(e.checked == false)");
strScript.Append("{");
strScript.Append("boolAllChecked = false;");
strScript.Append("break;");
strScript.Append("}");
strScript.Append("}");
strScript.Append("for(i=0; i<frm.length; i++)");
strScript.Append("{");
strScript.Append("e=frm.elements[i];");
strScript.Append("if ( e.type =='checkbox' && e.name.indexOf('checkAll') != -1 )");
strScript.Append("{");
strScript.Append("if( boolAllChecked == false)");
strScript.Append("e.checked = false ;");
strScript.Append("else if(boolAllChecked == true)");
strScript.Append("e.checked = true;");
strScript.Append("break;");
strScript.Append("}");
strScript.Append("}");
strScript.Append("}");
strScript.Append("</script>");
if (!this.IsClientScriptBlockRegistered("clientScriptCheckChanged"))
this.RegisterClientScriptBlock("clientScriptCheckChanged", strScript.ToString());
}
// Function to get the selected checkbox values
private string GetSelected()
{
// Initially set the values to Blank
h_chkSelected.Value = "";
foreach (GridViewRow di in GridView1.Rows)
{
HtmlInputCheckBox chkBx = (HtmlInputCheckBox)di.FindControl("chkBoxId");
if (chkBx != null && chkBx.Checked)
{
Label lbl = (Label)di.FindControl("RowId");
h_chkSelected.Value = h_chkSelected.Value + lbl.Text + ",";
}
}
// If no checkbox selected, do not proceed further
string strDataToSend = "";
if (h_chkSelected.Value != "")
{
//Strip off the last comma before sending to stored proc
strDataToSend = h_chkSelected.Value;
strDataToSend = strDataToSend.Substring(0, strDataToSend.Length - 1);
}
return strDataToSend;
}
protected void btnDelete_Click(object sender, EventArgs e)
{
// This variable contains the selected rows in the format 1,2,3
string SelectedRows = GetSelected();
// User defined function that calls the stored proc to delete the selected items
DeleteRows(SelectedRows);
}
public virtual void DeleteRows()//error No:2
{
int rowIndex;
}
}
|
|
|
|
|
premprakashbhati wrote: 1.---->'gridview.RetrieveItems()': not all code paths return a value
Your RetrieveItems() function states that it will return an object of type DataTable but there doesn't appear to be a single 'return' statement in this function. Write one.
premprakashbhati wrote:
2.----> No overload for method 'DeleteRows' takes '1' arguments
You're calling DeleteRows with a string parameter but this function signature doesn't exist. Write it.
premprakashbhati wrote:
so plz go through the code and help me out its urgent....
thanks in advance.....
That's all the help I'm giving.
It definitely isn't definatley
|
|
|
|
|
premprakashbhati wrote: help me out its urgent....
No. Not my problem.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
When ever I tried to connect with sql database in asp.net server exploror
then this massage come in sight that's why I am not able to access the database, I reinstalled both sql server 2005 and also management studio.But still facing same problem
Could not load file or assembly 'Microsoft.SqlServer.Management.Sdk.Sfc,Version = 10.0.0.0,Culture = neutral,
PublicKey Token = 89845dcd8080cc91' or one of its dependencies.
Kindly do replay.
Sajjad Ali
|
|
|
|
|
Why can't you just google it up the error and get the solution rather than waiting for one day?
Check this site. probably it may help you.
Sql Server Error
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
you are using vs2008? and you are trying to import this file. is it so?
Ahsan Ullah
Senior Software Engineer
MCTS 2.0
|
|
|
|
|
yes i am using vs 2008 but at the last i solved it,the problem is in
IDE of vs 2008
Its because when i import database in vs 2005 server explorer database then without any problem database easily imported.
Now sir i just want to know what was wrong with vs 2008.
Kindly do replay because it may be happen again.
Sajjad ALi
Junior web developer
110 Solutions
|
|
|
|
|
Import the Database in Visual Studio?
IN Visual Studio we connect the Sql Server Database and do not import it.
dont get confused.
|
|
|
|
|
can any one guide me that i want to fill two dropdown lists country and cities relevant to that.....
my requirement is to select country and its cities must be filled automatically... before that i used to do it by filling country and cities in database using primary and foreign key relationship....
is there any api or webservice available for that????
umerumerumer
modified on Thursday, December 4, 2008 6:25 AM
|
|
|
|
|
Use Update panels in Ajax so that the States will get automatically updated once you select the countries.
For code reference, please refere to this sites:
1) Experts Exchange
2)MSDN
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
Other then what meeram has suggested. You can do it through js as well.
Ahsan Ullah
Senior Software Engineer
MCTS 2.0
|
|
|
|