Add Service Reference In User Control?
Mar 11, 2010my user control i m calling the web service i added script manager in the web page how to add service reference in user control
View 2 Repliesmy user control i m calling the web service i added script manager in the web page how to add service reference in user control
View 2 RepliesI am trying to assign user control from another user control ..first time its binding control successfully but when we refresh the data its giving error
saying "Object reference is not set an instance".
how to refresh data from another user control ...
My senerio below :
1 Aspx page
2. User control
calling usercontrol databinding method from aspx page but once it get refreshed ,not allowed to bind it again..
I have created a web user control. It contains a table that has several image buttons. I want them to behave link a tab control. Here's the souce view:
Code:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ProcessMenuContrl.ascx.vb" Inherits="ProcessMenuContrl" %>
<table >
<tr>
<td><asp:ImageButton ID="imgCustomerInformation" runat="server" CausesValidation="false" ImageUrl="~/Images/TabButton_CustomerInformation.jpg" /></td>
[Code] ....
From another page, I have placed this user control into the main content of the form. I have registered it at the top of the page:
Code:
<%@ Register src="ProcessMenuContrl.ascx" tagname="ProcessMenuContrl" tagprefix="uc1" %>
Here's portion of the source where you can see the control is placed under the MainContent of the page. :
Code:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<link href="Styles/QuoteStyles.css" rel="stylesheet" type="text/css" />
<uc1:ProcessMenuContrl ID="ProcessMenuContrl1" imgOrderInformation="" runat="server" />
When the user saves information that's on a form from this same page, I want to enable one of the image buttons (imgOrderInformation).
The problem is that i don't know how to reference this image button that's on the user control.
I've been trying to use Findcontrol, but must be doing it wrong.
I have built a WCF Service that is being consumed by a Silverlight app. At first I created one method that was very simple:
public String SfTest()
{
return "SF Test";
}
No poblem. My silverlight app references my service and displays "SF Test" in a textbox. Now I add a method to my wcf service like this:
public List<String> GetTest()
{
List<String> list = new List<string>();
String a = "a";
list.Add(a);
String b = "b";
list.Add(b);
return list;
}
I update the reference to the service in my Silverlight app and the using statement in my xaml cs page throws an error like the service doesn't even exist although it is there. I am assuming the problem has to do with datatypes or serialization or something like that but it is driving me up the wall. Why can't I consume a simple generic list in my Silverlight app through the WCF service.
I'm currently trying to work out the best way to build this web application, which will then be intergrated on other systems, such as WinForms, Intranets etc.
We hope to include the usual layers i.e. DAL, BLL, BOL and UI but I have been experimenting with Entity Framework 4 and WCF Data Services and managed to get something in place where I was using WCF as a gateway to EF4.
i.e. Adding a Service Reference to my project and then using the EF4 context and writing LINQ queries against the DB
e.g.[Code]....
Now with the current setup I would still need to write a DAL Class Library, that interacts with the Data Service, because as I said WCF Data Services only seems to be a gateway, I can't see where to put the code (above) in the Data Service and then how I could these methods.
My questions are: 1. How do I develop a WCF Data Service in such a way to allow this behaviour - I know how I could do it using ASMX web service, something like [Code]....
2. If I am to use WCF Data Services, how is serialization handled (if at all) - again I know how to do something in ASMX web services
3. Again, If I am to use WCF, how do I add Security and only allow my applications to access the web service - for obvious reasons
4. Would it be possible / logical to also include the Business Logic Layer into the web service?
How to create an instance of web service without adding web service reference? How to identify the server address/name where the web service is hosted from C# code?
View 1 Replies<Application architecture>I'm developing ASP.NET Web Application by Visual Studio 2008.(.Net Framework Version = 2.0)I put followin two projetcs in the solution.a. Class library which implements all the buisiness logic for application.
(I'll call it "ClassLib" in the followin sentence)b. ASP.NET Web applicatoin which presents UI.(I'll call it "WebApp")ClassLib uses Web Service which located on other server. So, I set web reference in it. Method for url settings for this web reference is "Dynamic".
i am trying to enter a value into a texbox that is placed inside a user control called CollectionRequest. i have referenced this user control in my code behind and created an instance of it but i seem to get the above error when i try to enter some manual text. code as follows:
protected CollectionRequest collReq;
protected void Page_Load( object sender, EventArgs e )
{
collReq = (CollectionRequest)LoadControl("~/CollectionRequest.ascx");
TextBox _txt_address = (TextBox)collReq.FindControl("txt_Address");
_txt_address.Text = "thisi is an address";
control has been referenced in source file
<%@ Reference Control="~/CollectionRequest.ascx"%>
i am caling this code in my Approval.ascx.cs code. both the user controls are displayed together in the default.aspx page one above the other.
How do I add the WCF service built using VS2010 as a service reference to a Winforms app which is written in VB6?
View 1 RepliesHere is the contents of my test.ascx file:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="test.ascx.cs" Inherits="UserControls_test" %>
<p id="XXX">aaa</p>
and here is the contents of my test.ascx.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class UserControls_test : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
this.XXX.InnerHtml = "BBB";
}
}
I get an error when I refer to the id, "XXX" (underlined above) in code behind which reads: 'UserControls_test' does not contain a definition for 'XXX' and no extension method 'XXX' accepting a first argument of type 'UserControls_test' could be found (are you missing a using directive or an assembly reference?)
I have tried XXX.InnerHtml and I have tried this.XXX.InnerHtml and get same problem.
How do I successfully refer to ID'ed HTML elements in code behind?
I am stuck into a problem, i have a user control ProductListing.ascx that contains ListView binded to an object datasource, SelectMethod and SelectCountmethod are provided as well. Everything works fine but the problem started when i add another user control declarativlly Filter.ascx in the productListing.ascx. I want to assign value to a public property MaxPrice in Filter.ascx. I am trying to set this property in the SelectMethod of ObjectDataSource. Usercontrol "Filter.ascx" throws null reference exception when i try to set its MaxPrice Property.
I tried to acced the usercontrol in Databind method of ListView , it is accessible here but viewstate is empty at this point, i saved the value in viewstate in SelectMethod of objectDatasource but i cant access viewstate in ListView Databind. Its empty. Its a simple code and no rewriting to viewstate elsewhere.
Important: My Codebehind files are in a seperate project and .ascx files in seperate project
I' m using a web custom control to upload images and mark them as primary. all the flow is working fine but it fails to mark images as primary in a diffrent category(there are four categories in which we can load a image-,catalog,primary,misc).It works in - category but not in others when I debug it is failing at a condition in grey . If it is not an element of the Datalist item it would not even enter the loop. I' m lost and unable to find the reason.
View 2 RepliesUsing VS2008, I noticed that in Class Project I only have a choice of adding "service reference" where as in Web Application project, I have two choices "web reference" and "service reference".
I have used web reference. How is "service reference" different from web ref? and what's the major purpose of service ref?
I am getting an error when i try to add a service reference of a WCF service. Error details is below. My web service is hosted on a different server and my client is on different server. When i run the service directly from IE i can see the service but adding it in .net web application i get error.
[Code].....
I can load a generic user control just fine in my WCF service doing the following:
UserControl userControl= (UserControl) new Page().LoadControl("~/UserControls/MyControl.ascx");
However i can't seem to find any way to do this
MyControl myControl=(MyControl)userControl;
The reason i need to do this is because my user control has a custom property, person, I need to do the following:
myControl.Person=new Person();
essentially i need to simulate:
<%@ Reference Control="~/UserControls/MyControl.ascx" %>
which normally goes inside asp.net page or master-pages.any way of doing this in an Ajax Enabled WCF Service?
Usage :
[code]...
The problem is it gives me following error :
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 21: {
Line 22: base.OnInit(e);
Line 23: _ContentTemplate.InstantiateIn(BodyControlSpace);
Line 24: }
Line 25:
I'm creating a DLL with a reference to web services (I don't have the choice to do so) but I have to add web service references to the project that uses the DLL for it to work. Example, I have the DLL called API.DLL that calls a web service called WebService.svc that I want to use in a project called WinForm. First, I have to add a "Service Reference" to WebService.svc in API.DLL. Then, I add a reference API.DLL to WinForm but it doesn't work unless I also add a service reference to WebService.svc in WinForm.
View 4 RepliesI was trying to go through this tutorial:
[URL]
but when I tried to add the service reference to the silverlight app, the Add Service Reference window would show me that there was a service file, but the node wouldn't expand to show the rest of the files that contain the services and what not. I got this error instead:
"An error occurred during the processing of a configuration file required to service this request. review the specific error details below and modify your configuration file appropriately."
"Parser Error Message:There is no service behavior named 'AdventureWorks_WebServer.Service1Behavior'."
"Metadata contains a reference that cannot be resolved: 'http://localhost:55579/Service1.svc'.
The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.
If the service is defined in the current solution, try building the solution and adding the service reference again."
here's my web.config file:
[Code]....
I'm looking to create an instance of a user control programatically in a codebehind of a web site*. The only ways I've found to reference the class of the user control programatically have been:
Register the control in the web.config and drop the control on the page (works, but I don't want the control on the page as I want to dynamically add it). Add a <%@ Reference Control="Name.aspx"> to the aspx page at the top.
I would want to have any aspx page reference the control without having to put the <%@ Reference> declaration at the top of each page. I know I can "Register" controls in the web.config so I don't have to do that on every page, so I'm wondering if something similar exists for references. I'm almost certain I'm missing something about the whole registering/referencing concept, so perhaps just an explanation of what the best way to do this is in order.
*Web-site type project and not web application if this matters.
I have my own web service application with more then one .asmx file. Now i am not getting how can i reference web service with my web application as "Add Web Reference".
I want to connect with both asmx files at once. Means once i connect web service as add web reference and i can call both .asmx file from my code behind page.
http://geoss.compusult.net/wes/serviceManagerCSW/csw?request=GetCapabilities&service=CSWHow would i create the proxy classes for the service?More information HERE.The hosting service above is implementing an OGC standard (CSW). The schemas for this standard are hosted HERE. And they have some WSDLs HERE. If i was to place the URL to one of those WSDL into visual studio's "add reference/service" i get a list of web operations and will generate a reference. However, that will not work because it does not know about the true hosting provider. So i'm not quite sure what to do.
Edit #2:
Custom tool error: Failed to generate
code for the service reference
'ServiceReference1'. Please check
other error and warning messages for
details. D: empWebApplication2WebApplication2Service
ReferencesServiceReference1Reference.svcmap 1 1 WebApplication2
[code]...
I want to add web service reference but we are using proxy. Is there a way to bypass proxy and add web service reference?
View 1 RepliesWe inherited some code that makes use of a web service on an external server from a third party. Currently all the references are done in the project directly and thus compiled to that location and such. This issue we have is that there is a test and production server for the web service with different URLs.
Is there a simple means to make the web reference more dynamic so that it can be defined in a web.config and not require changing the actual source and recompiling to switch between servers?
I have a UI that communicates with a service. I made some changes to the service- added some code and a property in the Interface associated with the service. After I made the changes, I updated the service reference in my UI and I couldn't access my newly added property. I also tried deleting the reference and adding in back again, it still doesn't work. I get the following error:
xxxxxxx(filename) does not contain a definition for xxxx(propertyname) and no extension method accepting a first arguement of type xxxxx could be found(are you missing a using directive or an assembly reference?)
When I look in the Reference.cs file, I don't see the newly added property in it.
I have an ASP.net page that is creating a service reference to a WCF service and making calls in multiple places in my page. I instantiate the service reference in Page_Load and have an instance variable to store it:
private FooClient _serviceClient;
protected void Page_Load(object sender, EventArgs e)
{[code]...
I just discovered that I need to be disposing of the service reference when I am done using it or else the connections will be kept alive and will block incoming connections if I reach the max number of connections. Where would the best place to dispose of these references be? I was thinking of doing it on the OnUnLoad event.