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

SILENT POSTBACK 2 DIFFERENT SERVERS
How to get the client id with ct100$
FileUpload Control will be clear text in textbox after postback by dropdown
W3 Schools validation error with POSTBACK and buttons?
Google Wallet for digital goods stopped working
How SignalR manages connection between Postbacks
How to make false postback in asp.net mvc
How to stop postback in ajaxbeginform in asp.net mvc
Selenium2 WebDriver (Page factory) error after a postback (Element not found in the cache)
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

Categories

HOME
cygwin
xml
microsoftgraph
apache-flink
obfuscation
jetty
code-coverage
jax-ws
retrofit2
trac
endeca
ibeacon-android
cmdb
scrolltop
job-scheduling
wolframalpha
jersey-1.0
windows-xp
google-maps-autocomplete
symbols
undertow
ios10.2
postscript
opentk
progress-bar
spotipy
vex
event-flow
fossil
sharepoint-workflow
latitude-longitude
demo
chef-solo
spring-mvc-test
azure-arm
plaintext
portforwarding
lpsolve
file-sharing
proget
automapper-5
robomongo
chai-as-promised
excel-dna
cmp
jtree
baidu
taocp
vulcanize
wso2developerstudio
dimension
observablecollection
http-status-code-401
tracker-enabled-dbcontext
redis-cluster
cycle2
toran-proxy
django-urls
video-player
rubaxa-sortable
iced-coffeescript
dronekit-android
mirror
keyup
dnssec
kubuntu
zend-currency
infosphere-spl
at-job
filesplitting
metatrader5
entry-point
psr-4
insight.database
winginx
ios8-extension
android-framework
renderer
dsym
openargs
visual-studio-express
modular
gpars
nebula
cascadingdropdown
alice
extreme-programming
patricia-trie
correlated-subquery
appjs
inkcanvas
fitbounds
box2d-iphone
agility.js
exponentiation
metaweblog
objective-j
non-clustered-index
application-verifier
data-mapping
windows-identity
fault-tolerance

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