|
|
Hi all,
I have the following scenario: I have a web user control (ParentControl.ascx) which has a menu with 2 linkbuttons and a placeholder.
If I click on the first linkbutton, the control load dinamically a ChildControl1.ascx in the placeholder. The ChildControl1 is composed by 1 label and 2 buttons: if I press the first, the text of the label's text change to "Alfa". If I press the second, the label's text change to "Bravo".
If I click on the second linkbutton, the control load dinamically a ChildControl2.ascx in the placeholder. The ChildControl2 is composed by 1 label and 3 buttons: if I press the first, the text of the label's text change to "Qui". If I press the second, the label's text change to "Quo". If I press the 3th, the label's text change to "Qua".
If I run the web application I can see the linkbuttons. Clicking I can got the child control but the strange thing is the following. If I press on the a linkbutton (the first for example) and I try to click on a button of the child control nothing happen, the label text didn't change (even if there is a postback). If I press the same button (of che childcontrol) another time, the label's text change.
This strange thing happen only when I switch from a child control to the other.
This is the ParentControl's code:
public partial class ParentControl : System.Web.UI.UserControl<br />
{<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
if (ViewState["SelectedControl"] != null)<br />
{<br />
switch (ViewState["SelectedControl"].ToString())<br />
{<br />
case "Control1":<br />
PlaceHolder1.Controls.Add(LoadControl("ChildControl.ascx"));<br />
break;<br />
case "Control2":<br />
PlaceHolder1.Controls.Add(LoadControl("ChildControl2.ascx"));<br />
break;<br />
}<br />
}<br />
}<br />
protected void LinkButton1_Click(object sender, EventArgs e)<br />
{<br />
Control ctrl = LoadControl("ChildControl.ascx");<br />
PlaceHolder1.Controls.Clear();<br />
PlaceHolder1.Controls.Add(ctrl);<br />
ViewState["SelectedControl"] = "Control1";<br />
}<br />
protected void LinkButton2_Click(object sender, EventArgs e)<br />
{<br />
Control ctrl = LoadControl("ChildControl2.ascx");<br />
PlaceHolder1.Controls.Clear();<br />
PlaceHolder1.Controls.Add(ctrl);<br />
ViewState["SelectedControl"] = "Control2";<br />
}<br />
}
As you can see, I recreate all the dynamic control on the Page_Load event and I use the ViewState to store which type of child control to create.
Can you help me to understand osmething more about this strange behaviour?
Thanks
Regards
Federico
P.S. I didn't post all the code but tell me if it can help you to solve the problem.
|
|
|
|
|
You also need to dynamically link the button click events in your loaded controls to the sub that you have provided on the page.
|
|
|
|
|
Hello,
thanks for you reply but I don't understand what is the "sub provided on the page" that you talking about.......
Regards
Federico
|
|
|
|
|
How to retrieve outlook contacts from exchange server in ASP.NET ? i need to implement this in project. I have to retrive details of one contact using outlook information. Expecting help from forum ppl.
Thanks, T.G. Shiva
|
|
|
|
|
If you have Active Directory in your organisation you can use the System.DirectoryServices namespace, Google will provide may samples.
Otherwise you will have to use CDO, here is a link which may help[^].
|
|
|
|
|
Dear All,
I'm just learn ASP.Net. I make a website by using Visual Studio.Net 2005. I want to take data from table in SQL Server into my website.
But i do not know how to connect SQL Server with ASP.Net and take data from table to my website.
Thank before hand for your help.
Best Regard,
Sovann.
VB.Net
modified on Wednesday, January 09, 2008 3:34:56 AM
|
|
|
|
|
You will get many articles if you search for this. You need to use the following classes for doing this.
1 - SQLConnection
2 - SQLCommand
3 - SQLDataAdapter
4 - DataSet/DataTable/SQLDataReader
|
|
|
|
|
Thank you for your help.
But i'm a new asp.net so i don't know much about that.
I would like you to show me detail about that.
If used ODBC connection.
what sourse for writing ?
VB.Net
|
|
|
|
|
Sovann wrote: But i'm a new asp.net so i don't know much about that.
Explaining the whole stuff through forums is too tough. Consider reading the books online or buying an ASP.NET book
|
|
|
|
|
|
Thank you so much Janet.
But like what i post before i don't know much asp.net. I'm a new one and i just get first project which less time of deadline. So I try to get some knowledge in this site from you and other.
If posible i would like you to show method about that.
Thank you in advance.
VB.Net
|
|
|
|
|
If i readed the books or bought asp.net, I don't ask you and CodeProject.
I have less time for doing my website so that i ask in CodeProject.
I think that there are kind people have to share some knowledge to me.
Ok it's nothing if you don't want to help me.
Thank you for your spend valuable time to me.
I will try more or wait someone's help else.
VB.Net
|
|
|
|
|
How many time you will wait Sovann? If no one helps you, will you wait for years?
Why don't you try to learn yourself? That is the best method eventhough it is time consuming.
don't look for spoon feeding like a baby.
|
|
|
|
|
Sovann wrote: If i readed the books or bought asp.net, I don't ask you and CodeProject.
I have less time for doing my website so that i ask in CodeProject.
The reason why I have not answered your question here is, it's too vague to answer through a forum. Internet got tons of articles for this. I have given you all the possible classes used for this. Why don't search for some articles which explains how to use them instead of wasting time for asking this here and waiting for reply ?
|
|
|
|
|
how to show the image in table control from database?
|
|
|
|
|
Did you try searching Google[^] before posting?
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
Hi All,
I am new in Asp.Net.I am building a side that enables user to buy online articles..obviously, some code on the server side and some is on client side..How these can be written???
Thanks in advance.
Regards,
chanzeb chaudhary.
|
|
|
|
|
chanzeb wrote: obviously, some code on the server side and some is on client side..How these can be written???
This forum is for specific ASP.NET questions. If you don't know anything about the technology, I suggest you visit the ASP.NET website[^] or buy a beginner's book and work through it.
Paul Marfleet
"No, his mind is not for rent
To any God or government"
Tom Sawyer - Rush
|
|
|
|
|
I have stored image for employee in the database as binary data..
now i want to display this image from the database with other informations in the same page image control.
do any other method for this except
response.contenttype="...jpeg";
response.binarywrite=dr["image"];
plz help me soon........
|
|
|
|
|
Yes, the other way is to write a page handler for a custom extension, which returns the byte data and can be used to embedd the images in a page. The best way IMO, is just to store the images in the file system, and their paths in the database.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Thank you very muchc for ur valuable reply...
But i didnt Understand it...[ ]
|
|
|
|
|
hi ! all
i have put div in datagrid control and i want to find div in itemboud event of datagrid.
harun
|
|
|
|
|
Your best bet is to add a literal, find it in the event and stuff your div in there. Although, I believe you can just use runat="server" and then search for it by id.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
How to dynamically resize the image from database?
|
|
|
|