在webview中根据月份的日期和时间显示不同的html页面 [英] Display different html pages according to date and time of the month in a webview

查看:275
本文介绍了在webview中根据月份的日期和时间显示不同的html页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我在我的应用程序中有不同的html页面,我想在我的应用程序中本地查看下面的代码只能查看单个html页面,但我想要的是显示不同的

。根据webview中月份日期的html页面

这是我下面的代码

xaml

Hi I have different html pages in my app that i will like to view locally in my app the code below can only view single html page but what i want is To display different
html pages according to date of the month in a webview
This is my code below
xaml

<!--ContentPanel - place additional content here-->
        <grid x:name="ContentPanel" grid.row="1" margin="12,0,12,0" xmlns:x="#unknown">
            <phone:webbrowser horizontalalignment="Left" margin="20,50,0,0" name="webBrowser1" verticalalignment="Top" height="500" width="430" xmlns:phone="#unknown" />
        </grid>

xaml.cs

xaml.cs

public partial class MainPage : PhoneApplicationPage
    {
        private List<string> htmls;

        private int CurrentIndex = 0;

        private int TotalCount = 0;
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Sample code to localize the ApplicationBar
            //BuildLocalizedApplicationBar();

            this.Loaded += MainPage_Loaded;
        }

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            htmls = new List<string>() { "/Bible/hymnpage1.html", "/Bible/hymnpage2.html", "/Bible/hymnpage3.html", "/Bible/1_1_2016.html" };
            TotalCount = htmls.Count;
            if (TotalCount != 0)

            {
                webBrowser1.Navigate(new Uri(htmls[CurrentIndex], UriKind.Relative));
            }

        }

        private void Previous_Click(object sender, EventArgs e)
        {
            if (CurrentIndex != 0)
            {
                CurrentIndex--;
            }

            webBrowser1.Navigate(new Uri(htmls[CurrentIndex], UriKind.Relative));
        }

        private void Next_Click(object sender, EventArgs e)
        {
            if (CurrentIndex != TotalCount - 1)
            {
                CurrentIndex++;
            }

            webBrowser1.Navigate(new Uri(htmls[CurrentIndex], UriKind.Relative));
        }

请帮助



我尝试过:



尝试了其他开发者论坛没有给出直接的解决方案

Kindly help

What I have tried:

Have tried other developer forums there was no direct solution given

推荐答案

DateTime类存储日期信息。它具有年,月,日,小时,分钟,秒等属性。 DateTime.Now返回当前日期和时间。是否有任何特殊原因不使用它来从您的html文件数组中进行选择?
The DateTime class stores date informations. It has properties like, Year, Month, Day, Hour, Minute, Seconds. DateTime.Now returns the current date and time. Is there any particular reason for not using it for the selection from your array of html files ?


这篇关于在webview中根据月份的日期和时间显示不同的html页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆