下面的代码我必须写成两三行........ [英] below code i have to write in 2 or three lines ........

查看:55
本文介绍了下面的代码我必须写成两三行........的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的代码中,我必须写两行或三行代码,我该怎么写呢?这可以帮助任何人……..


这是我的第一页....

below code i have to write in 2 or three lines how can i write this can any one help plzzzz..........


this is my first page....

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class Default2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }
    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            Response.Write("you have sucessfully registred...!!!");
        }
    }

    protected void btnsubmit_Click1(object sender, EventArgs e)
    {
        Application["DEMO_APPLICATION"] = txtname.Text;
        Application["DEMO_APPLICATION1"] = txtpwd.Text;
        Application["DEMO_APPLICATION2"] = txtpassword.Text;
        Application["DEMO_APPLICATION3"] = txtadd.Text;
        Application["DEMO_APPLICATION4"] = txtfull.Text;
        Application["DEMO_APPLICATION5"] = DropDownList1.SelectedIndex;
        Response.Redirect("default3.aspx");


    }
  }


this is my second page:-

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Data;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Default3 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        TextBox1.Text =Application["DEMO_APPLICATION"].ToString();
        TextBox2.Text = Application["DEMO_APPLICATION1"].ToString();
        TextBox3.Text = Application["DEMO_APPLICATION2"].ToString();
        TextBox4.Text = Application["DEMO_APPLICATION3"].ToString();
        TextBox5.Text = Application["DEMO_APPLICATION4"].ToString();
        TextBox6.Text = Application["DEMO_APPLICATION5"].ToString();
    }
}

推荐答案



您不需要将文本框"值存储在应用程序"变量中.

PreviousPage.FindControl 可用于最小化Default2页面上的代码.

Default3页面上的必需代码.

Hi,

You do not need to store Textbox value in Application variable.

PreviousPage.FindControl could be used to minimize code on Default2 page.

Required code on Default3 page.

TextBox1.Text = ((TextBox) PreviousPage.FindControl("txtname")).Text;



但是再次在上述代码中,您需要检查 txtname 存在.因此,并非总是可能使行数最小化.但重要的是正确的行为然后进行优化.

希望对您有帮助.

谢谢
-Amit.



but again in above code you need checking for txtname existance. So, its not always possible to minimize number of lines. but the important thing is the correct behavior then optimization.

Hope this will help you.

Thanks
-Amit.


这篇关于下面的代码我必须写成两三行........的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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