|
Hi
I have a hiddenfield, which I want to save the scroll position of asp.panel scrollbar during postback, and when during postback this value is called back to set the scroll position.
Using javascript I can grab the value from the scrollbar, and assign it to the hidden field, but when I post the page back the value has gone.
Here is my code snippet:
<script type="text/javascript" language="javascript">
function SetScroll(val) {
alert(document.getElementById('div1').childNodes('ScrollPos').value);
}
function ScrollTo(what) {
var test = what.split('/');
document.getElementById(test[0]).scrollTop = document.getElementById('div1').childNodes('ScrollPos').value;
}
</script>
<div id="div1" class="Style">
<input type="hidden" id="ScrollPos" name="Pos" runat="server" enableviewstate="true"/>
<asp:Panel ID="pnl1" runat="server" Enabled="true" Height="600px" ScrollBars="Vertical"
Width="100%" onscroll="javascript:SetScroll(this);">
<br />
<div class="divTagBGColours">
</div>
<br />
<asp:BulletedList ID="BulletedList2" runat="server">
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
<asp:ListItem Text="Hello" Value="blah" />
</asp:BulletedList>
</asp:Panel>
</div>
protected void Page_PreRender(object sender, EventArgs e)
{
EnsureChildControls();
if (!IsPostBack)
{
Session["panelNames"] = pnl1.ClientID;
Session["panelNames"] += "/" + pnl2.ClientID;
Session["panelNames"] += "/" + pnl3.ClientID;
string var4 = Session["panelNames"].ToString();
Session["panels"] = "ScrollTo('" + var4 + "');";
((HtmlControl)(this.Page.Master.FindControl("mainBody"))).Attributes.Add("onload", Session["panels"].ToString());
string var = ScrollPos.Value;
}
}
Am I missing something? How do I keep the value during post back?
|
|
|
|
|
Does this help: Maintain Scroll Position on Postback[^]. Not checked it but it looks close to what you want. Took 1 second to Google that. Tychotics
"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven
|
|
|
|
|
That deals with maintaining the scroll position of the page, not an individual element within the page. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Yup, you're right: just saw scroll and maintain.Tychotics
"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven
|
|
|
|
|
maintainscrollposition does not work on asp:panels - I checked that too 
|
|
|
|
|
First, format the code you post using the pre tags
Second, Do not repost the same question, continue with the original thread. where everyone can see the previous responses and reply to gain context.
I know the language. I've read a book. - _Madmatt
modified on Friday, March 12, 2010 10:30 AM
|
|
|
|
|
It seems you are just throwing things together at this point with very little understanding of ASP.NET and hoping that it works.
I would suggest you step back, take some time to understand ASP.NET and in particular maintaining state for controls or values within a page, then come back to the problem at hand after you have the knowledge. I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi friends,
I have installed my website to server under Default website in IIS.
then i open a crystal report then it allows me to take print from crystal reports print option.
but when i add new website in iis (on clicking the website then new website and add new website).
then i installed my website their then i m not able to take print from crystal reports print option.
the images of print button in crystal report are not displayed on their places and when i click there it gives JavaScript error.
Please help me on this.
Regards,
Gourav Tyagi
|
|
|
|
|
Try reading a little about ASP.NET deployment[^] I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Hi all,
Could u pls tell me How do we find out During Month transactions took place in our Database. i want to find out only updated rows in current month from my database. multiple users r updating their data by ASP.Net pages. could u pls tell me how can i...
Thanks
************ S G KORE *******************
|
|
|
|
|
Do you have a date/time stamp on a transaction table?
If not you are out of luck, unless you only want the last update date/time of a record then you still need a date/time stamp on the record.
|
|
|
|
|
The content page on my website is loaded thru an xml.
Now I want to change the text box as a label evrytime there is a value returned from database otherwise a textbox. Currently it always returns a text box as below.
- <element type="cdu:CDUText" binding="Shares/IndividualShare[i]/FirstName" id="CDUText_FirstIndv" width="Narrow">
<validator type="cdu:CDURequiredValidator" id="CDURequiredValidator_FirstIndv" message="First Name is required" />
</element>

|
|
|
|
|
|
Hello,
I have a drop down list with some items.
I need to disable some items (not selectable) from this list.
How can i implement this.
Please reply..
|
|
|
|
|
I would have thought it better not to show them in the first place: you should never show a user options that thay have no access to: what would be the point?
For example, knowing the user you could tailor the list items to suit rather than faffing around trying to hide unwanted items.Tychotics
"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven
|
|
|
|
|
we can not disabled the few items of listbox better not to fill them.... Rating always..... WELCOME
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
|
Hi,
I have a need to send out emails to all the people who are in a given group say "HR Department". I need to be able to get all the emails through a for loop and then as it retrieves I should send emails to them. Can some one please help me with the code how to get the emails out of AD.
this is what I came up with but not sure how to go about writing a for loop to get all the emails in the given group. I am having difficulty to send both the loginName and the group that I am interested in to the AD in the search.Filter.
public static string SendEmails(string loginName)
{
string Department = "HR Department"
string userName = ExtractUserName(loginName);
DirectorySearcher search = new DirectorySearcher();
search.Filter = String.Format("(SAMAccountName={0})", userName);
//search.Filter = String.Format("(SAMAccountName={FAY ImprovmentForm})", userName);
//LdapSearcher.Filter = string.Format("(&(objectClass=user)(department={0}))", Department);
//search.Filter = string.Format("(&(objectClass=group)(SAMAccountName=" + Department + "))", userName);
search.PropertiesToLoad.Add("cn");
search.PropertiesToLoad.Add("samaccountname");
search.PropertiesToLoad.Add("givenname");
search.PropertiesToLoad.Add("sn");
search.PropertiesToLoad.Add("mail");
SearchResult result = search.FindOne();
string samaccountname = (string)result.Properties["samaccountname"][0];
string givenname = (string)result.Properties["givenname"][0];
string surname = (string)result.Properties["sn"][0];
string email = (string)result.Properties["mail"][0];
if (result == null)
{
return "User doesn't Exist";
}
else
{
return "Emails sent successfully!";
}
|
|
|
|
|
|
I have a datagrid control with horizontal and vertical scrollbars. Both scrollbars work properly on Windows XP machine, but when I deploy/run site on a Windows 2003 Server, I don't see the horizontal scrollbar. Also, all the columns get rearranged automatically. Any ideas what's wrong?
Thanks!
|
|
|
|
|
Are you talking about Windows Application or Web Application ?
|
|
|
|
|
|
Hi
I am using JavaScript which to store and retrieve a value from a hiddenfield in order to set a position of a scrollbar on an asp.panel during postback. Unfortunately, during postback the value doesn't seem to be set, and I can't see why.
Here is my code:
function setScroll(var)
{
document.getElementById('pnlCosts').childNodes('hiddenfield').value = val.ScrollTop;
}
function scrollTo(panelName)
{
document.getElementById(panelName).scrollTop = document.getElementById('pnlCosts').childNodes('hiddenfield').value;
}
I am refreshing using: Response.AddHeader("Refresh", strPageRefresh);
Can anyone help?
|
|
|
|
|
If you refresh a page it doesn't post back. It just reloads the page. If you want any form fields sent back you need to cause a postback not a refresh.
|
|
|
|
|
First, please format any code you post using the pre tags.
Are you updating the value in your hidden field during the postback, i.e. using viewstate or other techniques? If not then of course the value will be reset to the default state after each postback I know the language. I've read a book. - _Madmatt
|
|
|
|