Click here to Skip to main content
15,890,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to change user tag source file from code page.

Please help me to solve problem.

Actually i want to use different user control on change of variable so please tell me how to change source file from code page.
HTML
<%@ Register TagPrefix="uc" TagName="AdminMenu" src="~/UserControls/AdminMenu1213.ascx"%>


The control present at starting of design page above <!DOCTYPE> so thats why i cant find its reference ID.

the above line contains src in which i stored current years user control. so when i changed my current year it has to b changed. like above its current year is 12 so its using 1213 user control.
please help me to find the solution.


Thank you in advance!!!!!
Posted
Updated 16-Feb-12 23:05pm
v3
Comments
manognya kota 15-Feb-12 1:48am    
Its little unclear.Why cant that user control be on the same aspx?
vins555 15-Feb-12 2:09am    
Actually i have different usercontrol files based on year. when i set for particular year then by using src the source i m using that years user control but if i changed my current year to previous year i have to change again the src. so how can i avoid that n by programmatic change to that src file.
manognya kota 15-Feb-12 2:11am    
Can you post the code where you are changing the src?
vins555 15-Feb-12 2:16am    
cant post whole code but on design source code

<%@ Register TagPrefix="uc" TagName="AdminMenu" src="~/UserControls/AdminMenu1213.ascx"%>

here am changing src according to current year. every time i have change if the current year is changed nw the current year is 2012. so if i used the current 11 then have to change src to usercontrol1112
vins555 15-Feb-12 2:24am    
ok thanks i will try that solution

1 solution

Try this
'divmain' is and ID of <div> tag

C#
Control uc = new Control();
        string controlname = <your Year>
       
            switch (controlname)
            {

                case "1988":
                    uc = LoadControl("AdminDashboard.ascx");
                    divmain.Controls.Add(uc);
                    break;

                case "2011":
                    uc = LoadControl("media.ascx");
                    divmain.Controls.Add(uc);
                    break;
              }
 
Share this answer
 
v4
Comments
vins555 17-Feb-12 3:31am    
sorry i forgot to mention that its not in div tag is at starting of design page above <!DOCTYPE> so thats why i cant find its reference ID. rest no problem thank you for giving idea. just if possible tell me how i can find it as it doesn't contain any id.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900