I am using ajax toolkit -> Dropdown extender and have a gridview inside a dropdown list..
it is working quite well except for one massive problem.
Each time i do something(click on a control inside the gridview the dropdown closes)
i have to open it again to do the next thing.
For example:
open Dropdown
Click on textbox inside gridview
Dropdown closes
go to 1
Found here: http://www.dotnetcurry.com/ShowArticle.aspx?ID=167
You can open the drop down through javascript. Presumably when the user interacts with your control, as partial post back occurs through the update panel? If so, you might use this code in the PageLoad javascript event.
<body>
<form id="form1" runat="server">
<script type="text/javascript">
function pageLoad()
{
var d = $get('TextBox1');
d.click();
}
</script>
... ScriptManager and other Controls come here
</body>
</html>
Related
I am using ASP.NET
I have created a user control that look like this:
when pressing the + : the score is raised by 0.5 and the opposite for minus.
The user control contains an update panel, and the pages itself containing the script manager.
When I put this user control in page and NOT inside repeater, this works perfect.
When I put this as part of a repeater. this not work at all.
I tried to delete all the update panels and still not working.
This is the error I'm getting
Don't know how to fix this.
This is the code of the user control:
Often, this error shows due to not post back:
If(!IsPostBack){
// your controls code here
}
Or, Check is your web page not using <form> tag more than once:
<form id="form1" runat="server">
<form id="form2" runat="server">
<!-- Your user controls -->
</form>
</form>
You have to use only one <form> tag in your page.
Or, try in your *.aspx page like:
EnableEventValidation="false"
I have some linkbuttons to update my gridview which is in the middle of the page. Everytime I hit edit or delete etc the window scrolls to the top on the page that gets posted back. I want it to stay focused on the grideview. I have tried a javascript function but for some reason it did not work.
(edit: the following works as far as scrolling is concerned but prevents postback)
here is what I tried
<script type="text/javascript" language="javascript">
function goto() {
window.scrollTo(10, 1100);
}
</script>
<asp:LinkButton ID="lbtnGo" runat="server" OnClientClick="javascript:goto();return false;">GO</asp:LinkButton>
source
How can I do this?
Did you try with <%# Page MaintainScrollPositionOnPostback="true" %> in the page declaration?
Regards
Client-side event fires before server-side. So even if you scroll window to correct position - after postback you will be returned to the top. You can add the following code to your server-side LinkButton click event handler:
if (!this.IsStartupScriptRegistered("ScrollToGrid"))
{
String scriptString = "<script language=\"JavaScript\">";
scriptString += "window.scrollTo(10, 1100);";
scriptString += "</script>";
this.RegisterStartupScript("ScrollToGrid", scriptString);
}
this will add javascript block to your page after postback
There are, depending on the .NET framework properties available that can help one out:
ASP.NET 1.x: use SmartNavigation. ASP.NET 2.0: use MaintainScrollPositionOnPostBack. Use an UpdatePanel control to asynchronously update parts of a page
and the best way for this is UpdatePanel control to asynchronously update parts of a page
<form id="form1" runat="server" onsubmit="return CheckForm(this)">
<script type="text/javascript" language="javascript">
function CheckForm(frm)
{
if(CheckEntireForm(frm) == false)
return false;
}
</script>
Hello EveryBody Please help me to get solution
I've used a javascript function on form's onSubmit event like
which validates my page's textboxes etc.
NOTE: i am not using asp.net's validation. i have got my own validation classes
I've also used a dropdownlist with auto post back set to true
in asp.net 2.0 when dropdownlist's selected index is changed it
calls form's onsubmit while this did not use to happen in asp.net 1.1
I've used this on 140 pages in my website the worst case will be to call
CheckForm(this.form) on my save buttons client click on all the pages.
I am looking for a backword compatibility solution which can be applied at a single place
like web.config or some class etc.
i am using asp.net and javascript
You have forget to return the true - your form never submit.
I have a strange scenario wherein I am having to delete the data from the table once a report is generated. The data gets uploaded to the table when the user clicks on a "Generate Report" button on the web page.
My problem is that once the report is generated and shown on the report viewer control I don't want the user to click on the "Refresh" button on the ReportViewer pane. Is there a way I can hide it?
Forget it, very stupid of me. Its under "Toolbar" properties on the ReportViewer control. ShowRefreshButton.
Thanks :)
<rsweb:ReportViewer ID="viewerName" runat="server" ShowRefreshButton="false" AsyncRendering="false" SizeToReportContent="True" >
</rsweb:ReportViewer>
Do you have control over the web page? If so, add a bit of javascript that hides the button.
Using jQuery:
<html>
<head>
<script>
$(document).ready(function() {
$('#btnid').hide(); }
)
</script>
</head>
<body>
...
</body>
</html>
I've got a repeater on the page. The repeater is actually in an .ascx. In the repeater each item has a few things such as an Add button, and a couple of other fields.
What I am trying to the Container.DataItem but the one that relates to the Add button that was clicked. If the user clicks the add button in the repeater list, give me reference to the Container.DataItem for that related to the button in that ItemTemplate that the user just clicked.
The add button is really just a regular HTML hyperlink wrapped around a regular HTML image. I added an ID to the hyperlink but don't know how to really link the two and gain reference to the DataItem.
I'm all set and can fly with jQuery and do whatever client-side stuff I want.
Example of what I started:
<script type="text/javascript">
$(document).ready(function()
{
$(myUserControl.MyRepeater).
}
</script>
The repeater doesn't generate any HTML of its own. It'll only write what you tell it to write.
So what you'll have to do is somehow identify each item, preferably with unique id's in the HTML. That way you can gain access to it through the DOM.
For example, if the rendered markup looked like this then you could actually access "item1" via jquery:
<div id="item1">abc</div>
<div id="item2">def</div>
To accomplish this you might try something like this in your ItemTemplate :
<ItemTemplate>
<div id="item<%#Container.ItemIndex %>">bla</div>
</ItemTemplate>
The Repeater and the DataItems are server-side control which is available from the code-behind of your pages/controls. You cannot access it from client-side code (javascript).