Thanks for your reply.
In my real application, I'll be having several custom attributes for every
template column in my datagrid. On using hidden field for every of them will
result in increase in size of resulting HTML and in my opinion, using custom
attributes will be the most optimum solution.
I saw an article on codeproject sometime back which uses similar concept in
his VB.NET web application but I am not able to find that article now. So, I
can surely say that this type of behavior is not "impossible" for ASP.NET.
:-)
Any help will be appreciated for this problem.
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
wrote in message news:exugFSvNFHA.2736@TK2MSFTNGP09.phx.gbl...[color=blue]
> Developer:
> This simply isn't something that asp.net automatically takes care of.[/color]
It's[color=blue]
> actually quite impossible for ASP.Net to automatically do this. You can
> certainly take a look at:
>
http://www.openmymind.net/FAQ.aspx?documentId=1 which talks about why
> dynamically added options to a select don't show up in postback...and you
> can apply the same logic to your case.
>
> When a page is posted back, individual attributes aren't posted[/color]
back...this[color=blue]
> is just how HTTP works...ergo ASP.Net can't track changes. I find it
> curious how hidden fields aren't an option, since you are relying on
> viewstate (which is a hidden field) to do this for you...
>
> Karl
>
> --
> MY ASP.Net tutorials
>
http://www.openmymind.net/ - New and Improved (yes, the popup is
> annoying)
>
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
> come!)
> "The Developer" <piyushind@gmail.com> wrote in message
> news:eEC8N$uNFHA.3188@TK2MSFTNGP10.phx.gbl...[color=green]
> > Hi All,
> > I have a web application where I am adding a custom attribute to my[/color]
> ASP.NET[color=green]
> > text box control and changing value of that attribute at client side[/color][/color]
using[color=blue][color=green]
> > JavaScript. My problem is that changed value of that custom attribute is[/color]
> not[color=green]
> > reflecting back at server side. Any ideas about this problem?
> >
> > Server side code:
> > private void Page_Load(object sender, EventArgs e)
> > {
> > if (this.IsPostBack == false)
> > {
> > this.txtTarget.Attributes.Add("myCustomAttribute", "Server Side[/color]
> Value");[color=green]
> > this.txtTarget.Text = "Server Side Value";
> > }
> > else
> > {
> > Response.Write("Attribute Value In Page_Load: <b>"
> > + this.txtTarget.Attributes["myCustomAttribute"]
> > + "</b><br>");
> > }
> > }
> >
> > Client side code:
> > <script>
> > function setTextBoxAttribute()
> > {
> > var txtTarget = document.getElementById('txtTarget');
> >
> > alert('Old Attribute Value: ' +
> > txtTarget.getAttribute('myCustomAttribute'));
> >
> > txtTarget.setAttribute('myCustomAttribute', 'Client Side Value');
> > txtTarget.value = 'Client Side Value';
> > }
> > </script>
> >
> > PS: Using input hidden HTML control is not an option for me. I have to[/color][/color]
use[color=blue][color=green]
> > custom attributes anyhow.
> >
> >[/color]
>
>[/color]