Hi, Pratheek.

It looks like you're using the value from txtAddress as the path to the
file. This will only work if the   path is relative to the project root and
the file has its build action set to "content". E.g. for

   - Solution my-solution
      - my-project
         - References
         - Dir1
         - Dir2
         - Dir3
            - CliqueITSample.html

the URL would be returned by

NSUrl.FromFilename("Dir3/CliqueITSample.html");


Like I said, I haven't used PathForResource, so I'm not sure what's up
there, but I assume you would need to use the return value from that method
as the path in FromFilename(). Also, my guess is that the ".html" second
argument means you don't need the ".html" in the first argument.

--D.


On Wed, Jul 6, 2011 at 12:53 PM, Pratheek Katangur <
[email protected]> wrote:

> **
> Hello David,
>                   This is the piece of code from where I access the html
> files locally, but I am not able to view anything on the iphone web browser
> can you let me know where I am going wrong.I have the local html file in the
> same folder as the project folder on which I am working on.
>
>
>  protected void NavigateToUrl()
> {
> string url = this.txtAddress.Text;
>
> NSBundle.MainBundle.**PathForResource("**CliqueITSample.html","html");
> this.webMain.LoadRequest (new NSUrlRequest(NSUrl.**FromFilename(url)));
>  }
>
>
> Thanks,
> Pratheek
>
>  ------------------------------
> *From:* [email protected] [mailto:[email protected]] *On Behalf Of
> *David Moles
> *Sent:* Wednesday, July 06, 2011 11:41 AM
> *To:* Pratheek Katangur
> *Cc:* [email protected]
> *Subject:* Re: [MonoTouch] Help with the code snippet
>
> Hi Pratheek --
>
> It looks like you've got something like a mix of C# and Objective-C code
> there. In C# it would look more like:
>
> this.webMain.LoadRequest(new NSUrlRequest(NSUrl.FromFilename(...));
>
> As far as the file path, (the ... above), I haven't tried using the NS
> resource stuff at all; I just mark my html files with the "content" build
> action and use paths relative to the project root.
>
> But, if the resource stuff works, the method you're trying to call would
> look like:
>
>  NSBundle.MainBundle.PathForResource("cliqueitsample", "html");
>
> It takes some time to get used to translating Objective-C examples into C#
> for Monotouch, and the mapping isn't always intuitive. You might want to
> have a look at Miguel de Icaza's "Monotouch Rosetta 
> Stone<http://tirania.org/tmp/rosetta.html>"
> to get a feel for it.
>
> Best,
> David
>
> On Wed, Jul 6, 2011 at 8:26 AM, Pratheek Katangur <
> [email protected]> wrote:
>
>> **
>> Hello,
>>         I developed a project in mono develop which is required to display
>> html files on the web browser.I am able to display remote html files and
>> html files sitting on a local web server.Now I want to display local html
>> files on the web browser.I could find a code snippet online for the same but
>> I am not able to compile it successfully.Can you help me out whether there
>> is any problem with the code syntatically .
>> Here is the piece of code:
>>
>>  this.webMain.LoadRequest(**NSUrlRequest requestWithUrl(NSUrl
>> firleUrlWithPath(NSBundle mainBundle)pathForResource:@"**cliqueitsample"
>> ofType:@"html")isDirectory:No)**));
>>
>>
>>
>> Thanks in Advance,
>> Pratheek
>>
>> _______________________________________________
>> MonoTouch mailing list
>> [email protected]
>> http://lists.ximian.com/mailman/listinfo/monotouch
>>
>>
>
>
> --
> David Moles
> [email protected]
>
>
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch
>
>


-- 
David Moles
[email protected]
_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to