0

I am using Visual Studio 2013 for my Windows Phone App Development. I have to use

System.Web.UI.Page

in my code, but when I try to include it with:

using System.Web.UI;

It gives this error: The type or namespace name Web doesnot exist in namespace System

When I search for it in Object Browser, its there. How can I use it?

Cyral
  • 13,999
  • 6
  • 50
  • 90
pratpor
  • 1,954
  • 1
  • 27
  • 46
  • 1
    Add a reference to the .NET Assembly? – pinkfloydx33 Apr 23 '14 at 19:02
  • 2
    Assuming you get the reference working, I can't think of a good reason to have an instance of an ASP.NET Web Forms page in a Windows Phone app. Why are you doing that? – mason Apr 23 '14 at 19:04
  • plus I'm sure this has been asked before! – crashmstr Apr 23 '14 at 19:04
  • possible duplicate of [type or namespace name does not exist in the namespace](http://stackoverflow.com/questions/10140931/type-or-namespace-name-does-not-exist-in-the-namespace) – crashmstr Apr 23 '14 at 19:07
  • Windows Phone App's by design target a subset of the .NET base class library. Even though they are in the same namespace, under the hood, there are two different DLLs that provide the various components. – ajawad987 Apr 23 '14 at 19:16
  • @mason I was looking for some way to call JavaScript Functions of my WebPage from C# code without WebBrowser element. I came across a link on StackOverflow which suggested a method using Page and some other thing. – pratpor Apr 23 '14 at 19:18
  • @PratPor I can't imagine how that would work. Do you have a link to the tutorial? – mason Apr 23 '14 at 19:20
  • @mason I was referring this link. http://stackoverflow.com/questions/18931936/call-javascript-function-from-c-sharp I am not sure if it will work. But being naive to wp8, I thought of giving it a try – pratpor Apr 23 '14 at 19:27
  • No, that will not work. That's for an ASP.NET context, where the code is running on a web server. It won't work from a Windows Phone project. Why do you want to call a JavaScript function on a webpage anyways? – mason Apr 23 '14 at 19:30
  • @mason Actually I am using a WebBrowser element, defined in MainPage.xaml file to render my website. To call JS functions of my site, I am using `WebBrowser.InvokeScript()` method from MainPage.xaml.cs. But now some part of my App lies in AnotherClass.cs file. And I have to call some JS Functions from here also but now I cannot access the WebBrowser element – pratpor Apr 23 '14 at 19:39
  • Then pass the WebBrowser element as a function parameter to the function in `AnotherClass.cs`. Using ASP.NET WebForms `Page` is barking up the wrong tree. – mason Apr 23 '14 at 19:40
  • @mason Sure I will try doing that. Thanks for your help :) – pratpor Apr 23 '14 at 19:45

2 Answers2

5

In your project, you need to add a reference to the System.Web assembly which is located under:

C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Web

Also make sure you are targeting the full .NET Framework 4.0, not the Client Profile, as it does not contain the System.Web namespace.

Cyral
  • 13,999
  • 6
  • 50
  • 90
  • Hi. Its giving this error when I tried adding it: Type universe cannot resolve assembly. – pratpor Apr 23 '14 at 19:15
  • Check out [this](http://stackoverflow.com/a/15589921/1218281) answer, it may not be available in your case. EDIT: `System.Web` is unavailable in Windows Phone (See [this](http://stackoverflow.com/q/10899337/1218281)) – Cyral Apr 23 '14 at 19:16
  • Okay. Thanks. Will look for an alternative. – pratpor Apr 23 '14 at 19:21
4

You have to add the assembly System.Web to your project references.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325