c# - Building a URL in HTML with Text Box Values -
i adding button website take user website , fill in various variables text boxes on site.
here markup code html page:
<body> <form id="form1" runat="server"> <div> <asp:label id="firstnamelabel" runat="server" text="first name:" width="100px"></asp:label> <asp:textbox id="firstnametxtbox" runat="server" width="150px"></asp:textbox> <br /> <asp:label id="lastnamelabel" runat="server" text="last name:" width="100px"></asp:label> <asp:textbox id="lastnametextbox" runat="server" width="150px"></asp:textbox> <br /> <asp:label id="emaillabel" runat="server" text="e-mail address:" width="100px"></asp:label> <asp:textbox id="emailtextbox" runat="server" width="150px"></asp:textbox> <br /> <asp:label id="desclabel" runat="server" text="description:" width="100px"></asp:label> <asp:textbox id="desctextbox" runat="server" height="100px" width="150px"></asp:textbox> </div> <button class="button" style="height:20px;width:120px" onclick="<%# string.format("location.href='https://biznetsoftware.fastsupport.com/?first_name={0}&last_name={1}&email={2}&question= {3}",firstnametxtbox.text,lastnametextbox.text,emailtextbox.text,desctextbox. text) %>" id="joinchatbutton">join chat</button> </form> </body>
the page doesn't go destination url. doing wrong?
you can use code:
<%@ page language="c#" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default" %> <!doctype html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <script runat="server"> void joinchat(object sender, eventargs e) { string url = string.format("https://biznetsoftware.fastsupport.com/?first_name={0}&last_name={1}&email={2}&question={3}", firstnametxtbox.text, lastnametextbox.text, emailtextbox.text, desctextbox.text); response.redirect(url); } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:label id="firstnamelabel" runat="server" text="first name:" width="100px"></asp:label> <asp:textbox id="firstnametxtbox" runat="server" width="150px"></asp:textbox> <br /> <asp:label id="lastnamelabel" runat="server" text="last name:" width="100px"></asp:label> <asp:textbox id="lastnametextbox" runat="server" width="150px"></asp:textbox> <br /> <asp:label id="emaillabel" runat="server" text="e-mail address:" width="100px"></asp:label> <asp:textbox id="emailtextbox" runat="server" width="150px"></asp:textbox> <br /> <asp:label id="desclabel" runat="server" text="description:" width="100px"></asp:label> <asp:textbox id="desctextbox" runat="server" height="100px" width="150px"></asp:textbox> </div> <asp:button class="button" style="height:20px;width:120px" id="joinchatbutton" text="join chat" runat="server"onclick="joinchat" /> </form> </body> </html>
Comments
Post a Comment