postback


Cant assign values to variable in a user control on ajax postback… or something like that!


I have a simple user control which toggles between the visibility of a few images depending on the UserId. When the page is loaded for the first time, the userID is being assigned correctly (I'm debugging). However, there are two other buttons on the page for filtering the type of users, they are perform their functionality via Ajax (not the toolkit, but the normal javascript ajax)
When one of these buttons are clicked, the user control cant get the userid, it always comes up as Zero. Oh, btw, the usercontrol is in a DataRepeater, so it occurs for each of the user.. all the time.. or thats the Idea. I have several other pages like this, (none of them have ajax) and the user control has no problems whatsoever.
My User control code:
public partial class ucAuthorityBadges : BaseUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (UserId > 0 && UOBJ.GroupId > 0)
{
DataSet DS = new DataSet();
DS = huDataAccessLayer.dbTools.GetUserAuthority(UserId);
if (!utils.isDataSetEmpty(DS))
{
imgTeamBadge.Visible = Convert.ToBoolean(DS.Tables[0].Rows[0]["isTeam"]);
imgDoctorBadge.Visible = Convert.ToBoolean(DS.Tables[0].Rows[0]["isDoctor"]);
imgAdminBadge.Visible = Convert.ToBoolean(DS.Tables[0].Rows[0]["isAdmin"]);
imgVolunteerBadge.Visible = Convert.ToBoolean(DS.Tables[0].Rows[0]["isVolunteer"]);
imgBloggerBadge.Visible = Convert.ToBoolean(DS.Tables[0].Rows[0]["isBlogger"]);
}
}
}
}
And the Data Repeater is something like this:
<div class="profileContainer">
<asp:HyperLink Enabled='<%# Eval("isActive") %>' ID="profileName_link" runat="server" Text='<%# Eval("Username") %>' NavigateUrl='<%# "/Profile/" + Eval("Username") %>'></asp:HyperLink>
<img id="friend_image" runat="server" src="/css/images/icons/friend.gif" alt="friend" title="Friend" visible='<%# Convert.ToBoolean(Eval("isFriend")) %>' style="vertical-align:middle" />
<ucAB:AuthorityBadges ID="ucAuthBadge" runat="server" UserId='<%# Convert.ToInt32(Eval("UserId")) %>' />
<%# Eval("UserId") %>
<asp:Label ID="status_label1" Text=" · Friend Request Pending" style="font-size:small;" Visible='<%# Convert.ToBoolean(Eval("isFriendReqPending")) %>' runat="server" Font-Bold="false"></asp:Label>
</div>
Here, Immediately after the userControl line, I am printing the userid just to see if its valid (by <%# Eval("UserId") %> and the user id's are valid too. I dont understand why the User Control cant pick it up on ajax postback?
Any hint at this would be really great,
Thanks so much!
I think the problem here is that your execution code actually lies in the Page_Load event, which occurs before the repeater is DataBound. A solution to that would be to place your code that is currently in Page_Load into another public method, and then on ItemDataBound event you need to find your control and manually call the public method with the parameters you need. This way you will populate all the fields you need once the control has already initialized.
Hope that helps.

Related Links

converting time in query using to_char
How do I find my C# panel controls?
Get TextBox values entered before postback
CalendarExtender loose his value on postback
passing values using viewstate across postback in multiview
How do I do an http request upon successful Inno Setup install, for tracking purposes?
calculate sum of two numbers in asp.net without postback
Textbox inside a Repeater inside a Custom Server Control loses values
client-side values of dynamic control on postback
postback (a la ASP.NET) in other frameworks?
Cant assign values to variable in a user control on ajax postback… or something like that!
How to stop Telerik RadWindow from always reloading on the next PostBack
sending to paypal the “custom” variable on saved buttons ipn question
viewstate in reporting services
Keeping track of refinements made to page using ASPX (Breadcrumb trail)?
Inside what the TexBox value is posted back? ViewState or post back data?

Categories

HOME
phpword
codenvy
nunit
twig
mjml
youtube-data-api-v3
google-cloud-functions
3d-reconstruction
telegram-bot
pearson-correlation
mapbox
python-multithreading
discrete-mathematics
arangodb
categorical-data
reactive-programming
x-cart
comsol
atlassian
package-managers
mapstruct
connector
asp.net-core-webapi
rubymotion
systemtime
interpreter
beta
moses
maze
fragment-backstack
failover
gitlab-api
event-flow
cognos-bi
activexobject
raft
sql-server-ce
openalpr
node-mssql
filesystemwatcher
tasm
skylink
signal-strength
clang++
rserve
custom-font
reshape
type-theory
vibrate
reachability
rmongo
gets
cronexpression
docpad
google-cloud-console
vulcanize
rspec2
http-status-code-401
spreadjs
extjs-grid
batik
iced-coffeescript
osc
user-permissions
xmltype
mmwormhole
angular-gettext
android-vibration
imagefilter
spring-remoting
eclipse-kepler
artemis
away3d
windows-phone-8-sdk
node-blade
actiondispatch
superscrollorama
sqlclr
extreme-programming
uimanageddocument
os.system
faye
cgimage
entity-attribute-value
msr
cdonts
metaweblog
blender-2.49
wordprocessingml
cuda.net
google-wave
sifr3
change-management

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App