| |

VerySource

 Forgot password?
 Register
Search
Author: gluttony

Ask about the user control to pass values ​​to the aspx page

[Copy link]

1

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-9 20:00:01
| Show all posts
Brothers, come up with ideas. Wait online ...
Reply

Use magic Report

1

Threads

18

Posts

14.00

Credits

Newbie

Rank: 1

Credits
14.00

 China

Post time: 2020-1-9 22:00:02
| Show all posts
Can be written as properties, methods in user controls
Reply

Use magic Report

1

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-9 22:27:01
| Show all posts
I use the same method in ascx as the one upstairs.

public string SelectedValue
{
get
{
return this.DropDownList1.SelectedValue;
}
}

public string TextValue
{
get
{
return this.TextBox1.Text;
}
}

As a result, no.
Reply

Use magic Report

0

Threads

60

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-1-10 08:54:02
| Show all posts
I use the same method in ascx as the one upstairs.

public string SelectedValue
{
get
{
return this.DropDownList1.SelectedValue;
}
}

public string TextValue
{
get
{
return this.TextBox1.Text;
}
}

As a result, no.


This should work.
Put
Server.Transfer ("products.aspx")

Changed to
Response.Redirt
Take a look
Reply

Use magic Report

0

Threads

60

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-1-10 09:45:02
| Show all posts
This should be all right. What can't work? Can't get the value?
Post more code
Reply

Use magic Report

0

Threads

60

Posts

23.00

Credits

Newbie

Rank: 1

Credits
23.00

 China

Post time: 2020-1-10 10:18:01
| Show all posts
This should be all right. What can't work? Can't get the value?
Post more code
Reply

Use magic Report

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 United States

Post time: 2020-1-15 21:36:01
| Show all posts
Have you added an .ASCX instance to your .ASPX page?
such as:
<% @ Register TagName = "abc" TagPrefix = "my" src = "yourascx.ascx"%>
<my: abc id = "myAscx" runat = "server" />

protected System.Web.UI.WebControls.DropDownList dpList;
protected yourAscxClassName myAscx;

Then take out the property: myAscx.yourAttri
Reply

Use magic Report

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 Australia

Post time: 2020-1-16 00:45:01
| Show all posts
There was no test at the beginning. I just tested it. The above method is completely correct. You can set or get the property value of the user control.
Reply

Use magic Report

0

Threads

73

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-16 09:00:01
| Show all posts
The point is
protected yourAscxClassName myAscx; this sentence
Reply

Use magic Report

1

Threads

9

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

 Author| Post time: 2020-1-20 19:45:01
| Show all posts
zhouji700I will write it out and see if something is wrong

test.ascx

1.Textbox1
2.Botton

s
    public string keyword
    {
        get {return TextBox1.Text;}
    }
    protected void Button1_Click (object sender, EventArgs e)
    {
        Server.Transfer ("main.aspx");
    }


==================================

test.ascx into index.aspx page

<% @ Register Src = "test.ascx" TagName = "test" TagPrefix = "uc1"%>
And in index.aspx.cs

protected test myascx;

==============================

main.aspx.cs

    protected void Page_Load (object sender, EventArgs e)
    {
        Response.Write (myascx.keyword);
    }


Compiler Error Message: CS0103: The name "myascx" does not exist in the current context
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list