By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,662 Members | 1,141 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,662 IT Pros & Developers. It's quick & easy.

Basic simple dumb question

P: n/a
Someone PLEASE HELP ME!!!!!

All I want to do is a simple postback and grab the value from a textbox
on clicking a linkbutton like below, but the value is not writing to the
screen. I am frustrated with this seemingly simple task. I have
enabledviewstate=true on the @Page directive, and I tried using onclick
on the linkbutton, nothing. I know the event is firing because I can
set the value to a hardcoded string and get it to show. In addition, I
have the Page_Load

if (IsPostBack){UserNameLabel.Text = newUserName.Text;}

So I have no idea what the heck is the problem.

public void updateUserName(Object sender, CommandEventArgs e)
{

UserNameLabel.Text = newUserName.Text;

}

<form id=form1 runat=server>
<asp:Panel ID="userNamePanel" EnableViewState=true Runat="server">
<TR>
<TD>
<asp:label id="UserNameLabel" EnableViewState=True
Runat="server"></asp:label></TD>
<TD>
<asp:textbox id="newUserName" EnableViewState=true
Runat="server"></asp:textbox></TD>
</TR>
</asp:Panel>

<asp:Panel ID="updatePanel" Runat="server">
<asp:linkbutton class="lnav1" id="updateUserNameLink"
CommandArgument="shit" OnCommand="updateUserName" runat="server"
Text="Update">
</asp:linkbutton>
</form>

Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I can see some general errors you have
-Why do you have <tr> and <td> within the panel "userNamePanel"?
-You don't have a closing tag for panel "updatePanel"
"ItNerd" <no@no.no> wrote in message news:10*************@news.supernews.com...
Someone PLEASE HELP ME!!!!!

All I want to do is a simple postback and grab the value from a textbox
on clicking a linkbutton like below, but the value is not writing to the
screen. I am frustrated with this seemingly simple task. I have
enabledviewstate=true on the @Page directive, and I tried using onclick
on the linkbutton, nothing. I know the event is firing because I can
set the value to a hardcoded string and get it to show. In addition, I
have the Page_Load

if (IsPostBack){UserNameLabel.Text = newUserName.Text;}

So I have no idea what the heck is the problem.





public void updateUserName(Object sender, CommandEventArgs e)
{

UserNameLabel.Text = newUserName.Text;

}

<form id=form1 runat=server>
<asp:Panel ID="userNamePanel" EnableViewState=true Runat="server">
<TR>
<TD>
<asp:label id="UserNameLabel" EnableViewState=True
Runat="server"></asp:label></TD>
<TD>
<asp:textbox id="newUserName" EnableViewState=true
Runat="server"></asp:textbox></TD>
</TR>
</asp:Panel>

<asp:Panel ID="updatePanel" Runat="server">
<asp:linkbutton class="lnav1" id="updateUserNameLink"
CommandArgument="s**t" OnCommand="updateUserName" runat="server"
Text="Update">
</asp:linkbutton>
</form>

Nov 18 '05 #2

P: n/a
Typos when I cut and paste. It is correct and when I test the event
using a hardcoded value rather than trying to grab the textbox value it
works fine.

I just want to grab the textbox value, and I am still frustrated.
Thanks in advance for any help you can provide.
Raterus wrote:
I can see some general errors you have
-Why do you have <tr> and <td> within the panel "userNamePanel"?
-You don't have a closing tag for panel "updatePanel"
"ItNerd" <no@no.no> wrote in message news:10*************@news.supernews.com...
Someone PLEASE HELP ME!!!!!

All I want to do is a simple postback and grab the value from a textbox
on clicking a linkbutton like below, but the value is not writing to the
screen. I am frustrated with this seemingly simple task. I have
enabledviewstate=true on the @Page directive, and I tried using onclick
on the linkbutton, nothing. I know the event is firing because I can
set the value to a hardcoded string and get it to show. In addition, I
have the Page_Load

if (IsPostBack){UserNameLabel.Text = newUserName.Text;}

So I have no idea what the heck is the problem.

public void updateUserName(Object sender, CommandEventArgs e)
{

UserNameLabel.Text = newUserName.Text;

}

<form id=form1 runat=server>
<asp:Panel ID="userNamePanel" EnableViewState=true Runat="server">
<TR>
<TD>
<asp:label id="UserNameLabel" EnableViewState=True
Runat="server"></asp:label></TD>
<TD>
<asp:textbox id="newUserName" EnableViewState=true
Runat="server"></asp:textbox></TD>
</TR>
</asp:Panel>

<asp:Panel ID="updatePanel" Runat="server">
<asp:linkbutton class="lnav1" id="updateUserNameLink"
CommandArgument="s**t" OnCommand="updateUserName" runat="server"
Text="Update">
</asp:linkbutton>
</form>



Nov 18 '05 #3

P: n/a
I think your problem is here

if (IsPostBack){UserNameLabel.Text = newUserName.Text;}

Don't do that, these constructs usually look like this

if (!IsPostBack)
{
// do procedures only to be done first time page is loaded
}

Then keep your updateUserName the same, hopefully will work then.
"ItNerd" <no@no.no> wrote in message news:10*************@news.supernews.com...
Typos when I cut and paste. It is correct and when I test the event
using a hardcoded value rather than trying to grab the textbox value it
works fine.

I just want to grab the textbox value, and I am still frustrated.
Thanks in advance for any help you can provide.


Raterus wrote:
I can see some general errors you have
-Why do you have <tr> and <td> within the panel "userNamePanel"?
-You don't have a closing tag for panel "updatePanel"


"ItNerd" <no@no.no> wrote in message news:10*************@news.supernews.com...
Someone PLEASE HELP ME!!!!!

All I want to do is a simple postback and grab the value from a textbox
on clicking a linkbutton like below, but the value is not writing to the
screen. I am frustrated with this seemingly simple task. I have
enabledviewstate=true on the @Page directive, and I tried using onclick
on the linkbutton, nothing. I know the event is firing because I can
set the value to a hardcoded string and get it to show. In addition, I
have the Page_Load

if (IsPostBack){UserNameLabel.Text = newUserName.Text;}

So I have no idea what the heck is the problem.

public void updateUserName(Object sender, CommandEventArgs e)
{

UserNameLabel.Text = newUserName.Text;

}

<form id=form1 runat=server>
<asp:Panel ID="userNamePanel" EnableViewState=true Runat="server">
<TR>
<TD>
<asp:label id="UserNameLabel" EnableViewState=True
Runat="server"></asp:label></TD>
<TD>
<asp:textbox id="newUserName" EnableViewState=true
Runat="server"></asp:textbox></TD>
</TR>
</asp:Panel>

<asp:Panel ID="updatePanel" Runat="server">
<asp:linkbutton class="lnav1" id="updateUserNameLink"
CommandArgument="s**t" OnCommand="updateUserName" runat="server"
Text="Update">
</asp:linkbutton>
</form>



Nov 18 '05 #4

P: n/a
Thanks for the tip. I finally got it to work. The problem was
that I had <form> tags inside of my <form runat=server> tag.

I suppose the viewstate had no idea which form I meant to grab data from
and couldn't find it by the name.

Raterus wrote:
I think your problem is here

if (IsPostBack){UserNameLabel.Text = newUserName.Text;}

Don't do that, these constructs usually look like this

if (!IsPostBack)
{
// do procedures only to be done first time page is loaded
}

Then keep your updateUserName the same, hopefully will work then.
"ItNerd" <no@no.no> wrote in message news:10*************@news.supernews.com...
Typos when I cut and paste. It is correct and when I test the event
using a hardcoded value rather than trying to grab the textbox value it
works fine.

I just want to grab the textbox value, and I am still frustrated.
Thanks in advance for any help you can provide.
Raterus wrote:

I can see some general errors you have
-Why do you have <tr> and <td> within the panel "userNamePanel"?
-You don't have a closing tag for panel "updatePanel"
"ItNerd" <no@no.no> wrote in message news:10*************@news.supernews.com...
Someone PLEASE HELP ME!!!!!

All I want to do is a simple postback and grab the value from a textbox
on clicking a linkbutton like below, but the value is not writing to the
screen. I am frustrated with this seemingly simple task. I have
enabledviewstate=true on the @Page directive, and I tried using onclick
on the linkbutton, nothing. I know the event is firing because I can
set the value to a hardcoded string and get it to show. In addition, I
have the Page_Load

if (IsPostBack){UserNameLabel.Text = newUserName.Text;}

So I have no idea what the heck is the problem.

public void updateUserName(Object sender, CommandEventArgs e)
{

UserNameLabel.Text = newUserName.Text;

}

<form id=form1 runat=server>
<asp:Panel ID="userNamePanel" EnableViewState=true Runat="server">
<TR>
<TD>
<asp:label id="UserNameLabel" EnableViewState=True
Runat="server"></asp:label></TD>
<TD>
<asp:textbox id="newUserName" EnableViewState=true
Runat="server"></asp:textbox></TD>
</TR>
</asp:Panel>

<asp:Panel ID="updatePanel" Runat="server">
<asp:linkbutton class="lnav1" id="updateUserNameLink"
CommandArgument="s**t" OnCommand="updateUserName" runat="server"
Text="Update">
</asp:linkbutton>
</form>


Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.