Showing posts with label contains. Show all posts
Showing posts with label contains. Show all posts

Wednesday, March 28, 2012

Linkbutton in asp:reapeater - all in user control, needs to register linkbuttons with ajax

I have a master page with the ajax script manager on it.

the master page then has a user control, which contains an asp:repeater which renders asp:LinkButtons on the page, i need them to be registered with the script manager so that they will only cause page re-renering in the content.

The problem i am facing is getting access to the ScriptManager in the master page fron theRepeater1_ItemCommand event in the user control.

Any thoughts, THanks

To programmatically access the scriptmanager:

Dim sm as ScriptManager
sm = ScriptManager.GetCurrent(Page)

Linkbutton inside update panel not working and causing exception

I page that contains an update panel. this page has a linkbutton that redirects to a new page and opens that page in a a new window(the page redirected to displays a picture). This linkbutton has been working all along with after adding this line of code in the pageload event.

ScriptManager.GetCurrent(Page).RegisterPostBackControl(LinkButton23)

suddenly, the linkbutton can nolonger redirect to the page when clicked and iam not aware of anything i did that may have crewed it up. I now get the following error message when i click it.

sys.webforms.webrequestmanagerParsererrorException: The message recieved from the server could not be parsed . Common causes for this error are when the response is modified by calls to response.write(), response.filters or server trace is enabled. Details: Error parsing near '<script language="ja'.

Actually i have noticed very strange behaviours by my IDE since i installed windows updates on tuesday, things like button click events not firing.

Any help.

Iam not sure if this extra information may help me get a reply. After some googling, most results are pointing to some thing to do with response.write in an update panel.

And in side the click event of my linkbutton, i have these javascript lines of code

ProtectedSub LinkButton23_Click1(ByVal senderAsObject,ByVal eAs System.EventArgs)

Dim myScriptAsString ="<script language=""javascript"">window.open('human Resources/viewer.aspx?id=" + employeenumber.SelectedValue +"') </" +"script>"

Response.Write(myScript)

EndSub

Iam not sure if this could be the cause of the problem but just in case.


<%@.PageLanguage="VB"AutoEventWireup="false" %>

I just changedAutoEventWireup from ="false" to="true" and every thing is back to normal, makes look stupid after wasting loosing over 8 hours. One more gotcha learnt though.

Saturday, March 24, 2012

Load huge data in GridView using AJAX

Hi all

I need help in griview and ajax question, lets say I have a table wich contains about 100 000 records and I need load them into gridview but it takes too long, how can I load it row by row lets say first row is loaded and others show some "Loading... " message ans so on.

Thanks in advance.

One thing more, may be somebody knows how to hide an update panel when update progress is firing?

Hi,

Please refer to this sample:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager>  </div> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </ContentTemplate> </asp:UpdatePanel> <asp:Button OnClientClick="" ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>
using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass Default2 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) { Button1.OnClientClick ="document.getElementById('UpdatePanel1').style.display='none';"; BindData(); }static DataTable source;protected void BindData() {if (source ==null) { source =new DataTable(); source.Columns.Add("column 1"); source.Columns.Add("column 2"); } DataRow row = source.NewRow();// you can use datareader to get data from database here row[0] = DateTime.Now.ToString(); row[1] = DateTime.Now.ToString(); source.Rows.Add(row); GridView1.DataSource = source; GridView1.DataBind(); }protected void Button1_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(2000); }}

Please note here use nested UpdatePanel to achieve your second requirement of hide a panel.

Another thing you must pay attenation to is that such a function will cause a higher network traffic.

Hope this helps.

Load On-demand using PopupControlExtender

Hi-

I am displaying a Panel that contains a web usercontrol using PopupControlExtender in AJAXToolKit. Since the web usercontrol has pretty expensive database task, I would like to display the Panel only when a user clicked on a link that displays the PopupControlExtender.

Is there a way to accomplish this? Please advice.

Regards,

Prabhu

Hi Prabhu,

According to my understanding to your question, you plan to load contents of a popup dynamically via asynchronous request.

Here isa thread that implement dynamical loading with TabContainer extender, you may try the same solution. The only difference is that you may need to invoke the method that fetches data in popup showing event handler. For instance:

<ajaxToolkit:PopupControlExtender ID="PopupControlExtender2" runat="server"BehaviorID="pce" ......... />
function pageLoad(sender, args)
{
$find("pce")._popupBehavior.add_showing(onPopupShow);

}

function onPopupShow(sender, args)
{
// get data dynamically here
}

Hope this helps.

Wednesday, March 21, 2012

Loading an Accordian

I am using an ajax accordian pane within an ajax tabpanel.
I dont want the accordian to load until the tab is clicked because it contains many images and is causing the page to load very slowly.
How can I make the accordian not load until the tab is clicked?

<ajaxToolkit:TabPanelID="TabPanel5"runat="server"HeaderText="Loft's & Condo's">
<ContentTemplate>
<tablestyle="height:400px;">
<tr>
<tdalign=center>
<uc1:Developmentsrunat="server"Visible=falseid="developments"></uc1:Developments> -------> //This contains the "Accordian"
</td>
</tr>
</table>
</ContentTemplate>
</ajaxToolkit:TabPanel>

u can create accrodian panel , when tab is clicked..

so it will not loading, when page is loaded.


You can use this approach...http://blogs.msdn.com/sburke/archive/2007/06/13/how-to-make-tab-control-panels-load-on-demand.aspx.

-Damien


Thanks for the reply, I am no sure how I would go about doing that...??


tmiller3:

I am no sure how I would go about doing that...??

Have you tried following the example?


Hey,

Thanks. I tried using that example but it is not working.

Here is my code

<hr>

function findControl(parent, tagName, serverId)

{

var items = parent.getElementsByTagName(tagName);

// walk the items looking for the right guy

for (var i = 0; i < items.length; i++)

{

var ctl = items[i];if (ctl && ctl.id)

{

// check the end of the name.

//

var subId = ctl.id.substring(ctl.id.length - serverId.length);

if (subId == serverId)

{
return ctl;

}

}

}

returnnull;

}

function loadTabPanel(sender, e)

{

var tabContainer = sender;

if (tabContainer)

{

var updateControlId ="TabButton" + tabContainer.get_activeTabIndex();

// get the active tab and find our button

//

var activeTab = tabContainer.get_activeTab();

// check to see if we've already loaded

//

if (findControl(activeTab.get_element(),"div","TabContent" + tabContainer.get_activeTabIndex()))return;

var updateControl = findControl(activeTab.get_element(),"input", updateControlId);

if (updateControl)

{

// fire the update

//

updateControl.click();

}

}

}

 
<ajaxToolkit:TabContainerID="TabContainer"runat="server"ActiveTabIndex="0"OnClientActiveTabChanged="loadTabPanel">
<ajaxToolkit:TabPanelID="TabPanel5"runat="server"HeaderText="Loft's & Condo's">
 <ContentTemplate>
 <asp:UpdatePanelID="up1"runat="server">
 <ContentTemplate>
 <asp:ButtonID="TabButton1"runat="server"OnClick="TabButton_Click"style="display:none;"/>
 <asp:PanelID="TabContent1"runat="server"Visible="False">
 <tablestyle="height:400px;">
 <tr>
 <tdalign=center>
 <uc1:Developmentsrunat="server"id="developments"></uc1:Developments>
 </td>
 </tr>
 </table>
 </asp:Panel>
 </ContentTemplate>
 </asp:UpdatePanel>
 </ContentTemplate>
</ajaxToolkit:TabPanel>
 
 protectedvoid TabButton_Click(object sender, System.EventArgs e)

{

string containerID ="TabContent" + TabContainer.ActiveTabIndex;

Panel panel = (Panel) TabContainer.ActiveTab.FindControl(containerID);

if (((panel !=null)))

{

panel.Visible =true;

}

}

 

Hi

It works:

<%@. Page Language="C#" %>

<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)
{
TextBox1.Visible = true;
}
protected void TabButton_Click(object sender, EventArgs e)
{
TabContent1.Visible = true;
}
</script>

<script language="javascript" type="text/javascript">
function loadTabPanel()
{
document.getElementById("<%= TabButton1.ClientID %>").click();
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<ajaxToolkit:TabContainer ID="TabContainer" runat="server" ActiveTabIndex="0" OnClientActiveTabChanged="loadTabPanel">
<ajaxToolkit:TabPanel ID="TabPanel5" runat="server" HeaderText="Loft's & Condo's">
<ContentTemplate>
<asp:UpdatePanel ID="up1" runat="server">
<ContentTemplate>
<asp:Button ID="TabButton1" runat="server" OnClick="TabButton_Click" Style="display: none;" />
<asp:Panel ID="TabContent1" runat="server" Visible="false">
<table style="height: 400px;">
<tr>
<td align="center">
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:TextBox ID="TextBox1" runat="server" Visible="false">sddsf</asp:TextBox>
</td>
</tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
</div>
</form>
</body>
</html>

I think your javascript has some logical error,so your code doesn't work. Please dubble check it!

Best Regards!