c# - not able to redirect users to another page with hyper link -


i have requirement users redirected youtube.com using hyperlink control using below

i want change url dynamically based on drop down list selected item using below code.

protected void ddlptype_selectedindexchanged(object sender, eventargs e) {     int x = ddlptype.selectedindex;      if (x == 0)     {         activatecerts.navigateurl = "http://www.youtube.com/watch?v=3ayoipyqokq";         activatecerts.text = "activatecerts";         activatecerts.target = "_blank";         //activatecerts.href = "http://www.youtube.com/watch?v=3ayoipyqokq";      }     else if (x == 1)     {         //activatecerts.target = "_blank";         //activatecerts.href = "http://www.youtube.com/watch?v=hk3hxuuwg0w";         activatecerts.text = "activatecerts";         activatecerts.navigateurl = "http://www.youtube.com/watch?v=3ayoipyqokq";      } 

and 1 aspx code

<asp:label runat="server" style="padding-left:23rem;" text="pls watch video on how to"></asp:label>                 <asp:hyperlink id="activatecerts"  runat="server"></asp:hyperlink> 

but when click on link not able open youtube video

this working me setting autopostback=true dropdpwn ddlptype :

<form id="form1" runat="server"> <div>     <asp:dropdownlist runat="server" id="ddlptype" autopostback="true" onselectedindexchanged="ddlptype_selectedindexchanged">         <asp:listitem text="option 1"  selected="true" />         <asp:listitem text="option 2" />     </asp:dropdownlist> <br />     <asp:label id="label1" runat="server" style="padding-left:23rem;" text="pls watch video on how to"></asp:label>             <asp:hyperlink id="activatecerts"  runat="server"></asp:hyperlink> </div> </form> 

.cs page :

   protected void ddlptype_selectedindexchanged(object sender, eventargs e)     {         int x = ddlptype.selectedindex;          if (x == 0)         {             activatecerts.navigateurl = "http://www.youtube.com/watch?v=3ayoipyqokq";             activatecerts.text = "activatecerts";             activatecerts.target = "_blank";             //activatecerts.href = "http://www.youtube.com/watch?v=3ayoipyqokq";          }         else if (x == 1)         {             //activatecerts.target = "_blank";             //activatecerts.href = "http://www.youtube.com/watch?v=hk3hxuuwg0w";             activatecerts.text = "activatecerts";             activatecerts.navigateurl = "http://www.youtube.com/watch?v=3ayoipyqokq";          }     } 

Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -