Title Bar.. Dynamic Data

  • Thread starter Thread starter Bilal Dhavan
  • Start date Start date
B

Bilal Dhavan

I am using ASP.Net with .Net Framework 1.1.



I want to display account number in the windows title bar. The data that I
am going to display will be from server side control (txtAcountNo.text).

I can use the following statement to display the title.



<title>

<% = txtAcountNo.value %>

</title>



But the problem is if the user changes the txtAccountNo.text value while
working with the program it is not getting reflected in the title bar.
Programming point, I am resubmitting the page to change txtAccountNo.text.

This approach may be not a good one.

Any other approach?

Thanks,

Bilal
 
Hi Bilal,

How about using some JavaScript to change the title dynamically?

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
txtAcountNo.Attributes.Add("onblur", _
"document.title=this.value;")
End Sub

<HTML>
<HEAD>
<title>

<% = txtAcountNo.text %>

</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<P>
<asp:TextBox id="txtAcountNo" runat="server"></asp:TextBox></P>
<P>
<asp:Button id="Button1" runat="server" Text="Button"></asp:Button></P>
</form>
</body>
</HTML>
 
Bilal Dhavan said:
I am using ASP.Net with .Net Framework 1.1.



I want to display account number in the windows title bar. The data that I
am going to display will be from server side control (txtAcountNo.text).

I can use the following statement to display the title.



<title>

<% = txtAcountNo.value %>

</title>



But the problem is if the user changes the txtAccountNo.text value while
working with the program it is not getting reflected in the title bar.
Programming point, I am resubmitting the page to change txtAccountNo.text.

This approach may be not a good one.

Any other approach?

Thanks,

Bilal

Greeting Billal,

This is what it should happen since you are not adding any handler
when user changes value in textbox.

Two solutions:

-Add a javascript handler. Choose an event for txtAccountNo from the
event menu , one could be onblur, then add this snippet code:

document.title=document.all("txtAccountNo").value


- Add a server-side event, ServerChange, for txtAccountNo then add
this snippet:

Response.write("<script>document.title=document.all("txtAccountNo").value
</script>")

Then place html control to enable a server trip so the code above can
be executed.

TTH,
Adel A. Al-saleh
 
Back
Top