How to set title as username of webpage that he or she gives in textbox using .net in visual studio

Design a webpage which has textbox and a button. User will enter his/her name in the textbox. On the click event of the button name of the user and current date time will be displayed on the titlebar of the web page. (Using Literal control).

Add Comment
1 Answer(s)

Hookup on click event for button. On post back get the string from the text box and set it on literal control.

void button1_Click(Object sender, EventArgs e) {     literalControl.Text = $"{Server.HtmlEncode(textbox1.Text)} - {DateTime.Now}"; } 

NOTE:- this is okay for very beginning, but getting user input and using it as such is dangerous!

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.