如何从文本框输入传递输入到ndfdgen()函数 [英] How do i pass input to ndfdgen() function from textbox inputs

查看:97
本文介绍了如何从文本框输入传递输入到ndfdgen()函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写以下代码,通过将输入传递到文本框来将输入传递给NDFDgen()函数。





我的ASP页面有2个纬度和经度文本框,提交按钮和标签。



我得到Point不在NDFD网格上异常,因为该方法被调用甚至在调用提交按钮之前。

任何人都可以帮助我。



我尝试过:



I am writing the below code to pass inputs to NDFDgen() function by passing inputs through the textboxes.


My ASP page has 2 textboxes for latitude and longitude, submit button and a label.

I am getting "Point is not on an NDFD grid" exception as the method is getting called even before submit button is invoked.
Could anyone please help me with this.

What I have tried:

    protected void Page_Load(object sender, EventArgs e)
    {

        decimal lat = String.IsNullOrEmpty(TextBox1.Text) ? 0 : decimal.Parse(TextBox1.Text);
        decimal lng = String.IsNullOrEmpty(TextBox1.Text) ? 0 : decimal.Parse(TextBox2.Text);

        //decimal lat = 42.3086M;
         //decimal lng = -83.4822M;
         

        Weather_Check.weatherParametersType wtp = new Weather_Check.weatherParametersType();
        wtp.temp = true;
        wtp.snow = true;
        Weather_Check.ndfdXML myobject = new Weather_Check.ndfdXML();

        string xml = myobject.NDFDgen(lat, lng, Weather_Check.productType.timeseries, DateTime.Now, DateTime.Now, Weather_Check.unitType.e, wtp);
        if (string.IsNullOrEmpty(xml) == false)
        {
            xml = xml.Substring(xml.IndexOf("Temperature"));
            Label1.Text = xml;
        }
 
    }
}

推荐答案

对不起,我发现了解决方案,我们必须将代码嵌入button1_Click()函数并正常工作
Sorry I discovered the solution, we have to embed the code in button1_Click() function and works fine


这篇关于如何从文本框输入传递输入到ndfdgen()函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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