|
How can I keep the page focused on a specific control after I've performed a postback?
I have a datagrid located on the bottom of my page. Each row contains a ButtonColumn, which when clicked, changes an image located alongside the grid.
My problem however is every time the user clicks a button in the grid, a Postback is performed and after the page refreshes, it returns the user back up to the top of the page (which can be quite annoying when you're performing clicks on 30-40 different rows).
So how can I prevent the page from returning back to the top every time?
Thanks.
-Goalie35
|
|
|
|
|
Add this function into your global module:
Public Function SetFocus(ByVal FocusControl As Control) As String<br />
'Setting focus to supplied control<br />
Dim Script As New System.Text.StringBuilder<br />
Dim ClientID As String = FocusControl.ClientID<br />
<br />
'Building java script<br />
With Script<br />
.Append("<script language='javascript'>")<br />
.Append("document.getElementById('")<br />
.Append(ClientID)<br />
.Append("').focus();")<br />
.Append("</script>")<br />
End With<br />
<br />
Return Script.ToString()<br />
End Function
Call the function above from your from passing control to be focused:
RegisterStartupScript("setFocus", Utilities.SetFocus(TextBox1))
==postmaster
www.programmingknowledge.com
|
|
|
|
|
use the MaintainScrollPositionOnPostback page directive
only two letters away from being an asset
|
|
|
|
|
Try this
Add this function into your global module:
Public Function SetFocus(ByVal FocusControl As Control) As String
'Setting focus to supplied control
Dim Script As New System.Text.StringBuilder
Dim ClientID As String = FocusControl.ClientID
'Building java script
With Script
.Append("")
.Append("document.getElementById('")
.Append(ClientID)
.Append("').Select();")
.Append("")
End With
Return Script.ToString()
End Function
Call the function above from your from passing control to be focused:
RegisterStartupScript("setFocus", Utilities.SetFocus(TextBox1))
|
|
|
|
|
This appears to be exactly, verbatim what postmaster@programmingknowledge.com posted about 2 hours before you.
Now the question is did you both copy it from the same source, did you copy from his post, or possibly is it from The Osmosian Order Handbook?
only two letters away from being an asset
|
|
|
|
|
The RowCommand is raised when a user presses a button on a GridView. Could someone please tell me how I can programmatically raise the RowCommand of within the event handler of another instance of an object? Paste some simple code if you can.
|
|
|
|
|
|
You can call any event just like you would any other method...you just need the right parms. The RowCommand event handler looks like this:
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
End Sub
So you have to send it an Object and a System.Web.UI.WebControls.GridViewCommandEventArgs
I don't know what all of the event arguments are, but you can use intellisense to help you figure out what you need...maybe this will help you get started:
Dim myOrginalArgs As New System.Web.UI.WebControls.CommandEventArgs(myCommandName, myArgument)
Dim myGridViewCommandEventArgs As New System.Web.UI.WebControls.GridViewCommandEventArgs(myGridViewRow, myOrginalArgs)
GridView1_RowCommand(myObject, myGridViewCommandEventArgs)
|
|
|
|
|
Hi,
In my C# Globals.cs class if the following varianble declaration and a property to retrieve this value:
private const String COMPANY_LONG_NAME = "J&D Ship Services";
And by using Globals.CompanyLongName I can print this "J&D Ship Services" in the web page. So after creating the e-mail link, it looks like this:
<a href="mailto:me@yahoo.com?Subject=Enquiry from J&D Ship Services">me@yahoo.com</a>
When I click on this link everything works well, except for the subject heading, it gets cut off after Enquiry from J.
How do I get this to work properly?
Regards
ma se
|
|
|
|
|
You could try and html encode the string.
|
|
|
|
|
Hello,
I created an Asp.Net 2.0 Access Data Source.
Is it possible to loop the loaded records and access each record field value?
Thanks,
Miguel
|
|
|
|
|
Plz don't post same question multiple times.
|
|
|
|
|
Hello,
I am working in ASP.NET 1.1
I am loading an image in a page on a button click.
Each time I click on the button the image is gettign loaded but until i refresh the page the image is not getting loaded into the page. How can i solve this problem.
|
|
|
|
|
Don't repost the same question.
With Regards
Satips
|
|
|
|
|
Hello Satips,
It was not purposly posted twice. DUe to browser problem it got posted twice. Take it easy
|
|
|
|
|
|
Sounds like you have the order of your code in page load and the button click wrong. Page load events will get called before the button click event.
|
|
|
|
|
I have a parameter on the Url, like,
http://localhost/mysite/groups.aspx?Group=Boys & Girls
When I attempt to decode the parameter Group from the groups.aspx code behind file as follows;
Dim Grp As String
Grp = Request.QueryString("Group").ToString,
the variable Grp ends up with only half the parameter value.
i.e. Grp = "Boys "
What can I do to get the whole parameter value
i.e. Grp = "Boys & Girls"?
I already tried putting two && as an escape sequence and it failed to work
|
|
|
|
|
The & character is used as separator between values in the query string, so you need to encode the character when it should be inside a value.
Actually you have to encode the entire value. An url may not contain spaces.
Use the Server.UrlEncode method to encode the value. The result should be: "Boys%20%26%20Girls".
---
b { font-weight: normal; }
|
|
|
|
|
Thanks.
Again I say Thanks.
|
|
|
|
|
how to -Develop a webpart which will display all the sites and sub sites.
For each site, it should display the name of all the web parts contained in that site.
This webpart when placed in any site should behave the same.
If any webpart in the site is hidden, specify accordingly.
using asp.net and c#
|
|
|
|
|
|
Is there any restriction in the length of the string we pass as Querystring with the Url?
Thanx
|
|
|
|
|
Yes there is a limitation for that you can only send 2047 characters maximum.
Best Regards,
Apurva Kaushal
|
|
|
|
|