Showing posts with label inside. Show all posts
Showing posts with label inside. Show all posts

Wednesday, March 28, 2012

Calling Clinet Function from Code Behind (Inside Ajax Update panel)

Hi,

Can anyone please provide information on how I can do this:

I have a GridView control inside an Ajax Update panel and have wired the Selected IndexChanged action to call a Client side Javascript function (ViewReceipt()). Unfortunately it doesn't seem to work except if I take the control outside the update panel.

Have posted my code below..

protected void rgvInv_SelectedIndexChanged(object sender, EventArgs e)
{
// Now execute the client-side stuff...
StringBuilder sbScript = new StringBuilder();
sbScript.Append("\n<script language=\"JavaScript\" type=\"text/javascript\">\n");
sbScript.Append("<!--\n");
sbScript.Append("ViewReceipt();\n");
sbScript.Append("// -->\n");
sbScript.Append("</script>\n");
this.RegisterStartupScript("ClientSideCall", sbScript.ToString());
}

Regards..

Peter.

Hi,

Found some posts on this and tried to add the recommended code but still getting a syntax error, hope someone can help out..

code behind:

protected void rgvInv_SelectedIndexChanged(object sender, EventArgs e)
{
// Now execute the client-side stuff...
StringBuilder sbScript = new StringBuilder();
sbScript.Append("\n<script language=\"JavaScript\" type=\"text/javascript\">\n");
sbScript.Append("<!--\n");
sbScript.Append("EditReceipt();\n");
sbScript.Append("// -->\n");
sbScript.Append("</script>\n");
//this.RegisterStartupScript("ClientSideCall", sbScript.ToString());
//ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "ClientSideCall", sbScript.ToString(), true);
ScriptManager.RegisterStartupScript(this, this.GetType(), "ClientSideCall", sbScript.ToString(), true);

}

Javascript Function:

function EditReceipt()
{
var manager = GetRadWindowManager();
var rwEntry = manager.GetWindowByName("rwReceipt");
}


Regards..

Peter.


Hi Peter,

The problem with your code is that you should specify the last parameter to false in RegisterStartupScript method.

This parameter indicates that <script> tag will be added automatically to wrap the sbScript. Since you've done that manually, so false should be used.

Like this:

ScriptManager.RegisterStartupScript(this, this.GetType(), "ClientSideCall", sbScript.ToString(), false);

Hope this helps.


Hi Peter,

Give full definition of EditScript() function then only I can help to you.

Regards,

Aru


Raymond,

Thanks for the information, I have already implemented a work around by moving the grid outside of the update panel. I'm using a telerik grid which has inbuilt AJAX and there are some clientside events which can be hooked into that has given me the functionality I require, anyway thanks for the information I can use it else where later.

Regards..

PeterBig Smile

calling a server side method to rebind and refresh a datalist in updatepanel without a ful

I have 2 datalists:

datalist1 (inside UpdatePanel1)

datalist2 (outside UpdatePanel1)

I have a ImageButton inside the datalist2 & when it is clicked, in the datalist2_ItemCommand event, I am updating some information in the database & calling a DataBind() on datalist1 & then calling an Update() method of UpdatePanel1.

This works fine, but my problem is that because of the datalist2_ItemCommand getting fired, a full postback occurs as well. How do I avoid this? I just want the datalist1 to be refreshed inside the UpdatePanel & not refresh the datalist2 at all.

If I use Web Service method, then I can do the database update in it, but I am unable to access the datalist1 to rebind it and also the UpdatePanel1 to update it.

Can someone please help me.

Thanks

Hi,

You canregister theItemCommand event ofdatalist2as a trigger of the UpdatePanel in whichdatalist1 is contained.

<Triggers>
<asp:AsyncPostBackTrigger ControlID="DataList1" EventName="ItemCommand" />
</Triggers>

Best Regards,


I had logged this issue in another forum my mistake and it got moved in this forum only after I logged it again as a new post (link below):

http://forums.asp.net/p/1180380/2000803.aspx#2000803

Thanks for your help.

Monday, March 26, 2012

Calling __doPostBack causing full postback :-(

Ok, if I capture an event on the client, for example, a click event on a textbox that is inside an update panel, and in that event I call __doPostBack I get a full postback.

However, if I add a button and call it's click event, I get the partial page update I want. So I guess the question is how to invoke a partial page update via script?

Thanks ... Ed

Make sure the appropriate trigger has been set up for the UpdatePanel. You can also set the TextBox to have AutoPostBack="true" which will add a __doPostBack to the onchange event handler.

Of course if you absolutely need to trigger a button click from JavaScript you can do something similar to this:

<

htmlxmlns="http://www.w3.org/1999/xhtml">
<headrunat="server">
<title>Untitled Page</title>
<scriptlanguage=javascript>
function SemiHacky(){
__doPostBack('Button1','');
}
</script>
</head>
<body>
<formid="form1"runat="server">
<asp:ScriptManagerID="ScriptManager1"runat="server">
</asp:ScriptManager>
<asp:UpdatePanelID="UpdatePanel1"runat="server">
<Triggers><asp:AsyncPostBackTriggerControlID=Button1EventName="Click"/></Triggers>
<ContentTemplate>
<asp:LabelID="Label1"runat="server"Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:ButtonID="Button1"runat="server"Text="Button"/>
<br/><br/>
<ahref="javascript:SemiHacky();">Click here</a> to execute some JavaScript and submit the Button1 button via JavaScript.
</form>
</body>
</html>

The code behind is just setting the Label text to the current time so you can see the PostBack occur:

Label1.Text =DateTime.Now.ToString();

Cheers,
Al


Hi,

I did exactly as you suggested, but to no avail.

I am trying to launch a modal dialog and I have tried the following variations, some of which seem to work correctly, except that once the modal dialog is display and I try to dismiss it via a server

side mydlg.close() I get an error stating "The control 'dlgDivTasks' already has a data item registered."

These are the individual calls that I have tried. I should point out that if I just to a plain __doPostBack("","") I get a full postback and no error when I try to dismiss the dialog.

_doPostBack('Button1','');
__doPostBack("","");
Sys.WebForms.PageRequestManager.getInstance()._doPostBack("","");
document.forms[0].ctl00_ContentPlaceHolderContent_Button1.click();
$find("DlgTasksBehavior").show();

Thanks ... Ed


Hi Ed,

Have you had any luck using the OnOkScript property of the ModalPupupExtender? One way that I use the modal popup is I have an Ok and Cancel button but they may be named differently based on user actions (ie. Cancel may be labelled as Close). I then use the OnOkScript to execute some client JavaScript which then uses a web service to pass the data back to the server for some processing.

OkControlID="btnOk"OnOkScript="modalOkScript()"CancelControlID="btnCancel"

function

modalOkScript(){
//TODO: Add some web service call to take care of my data processing requirements
}

When the Web Service completes, the onSuccess JavaScript function for the webservice in my OnOkScript function changes the 'Cancel' button text to 'Close.

function

onSuccessModalOkScript(result){
$get('btnOk').disabled =true;
$get('btnCancel').value ='Close';
}

Then it's finished and the Modal closes via client side when the user is ready.

Al


Looks like my copy / paste made the JavaScript functions look odd.

Hi, thanks for the reply.

Wouldn't what you suggest be kinda limiting? I wouldn't have access to the various data and controls on the page unless I passed a mountain of parameters the the service call. Seems to me I should just be able to do an async update via the update panel so I can use my server side code to get the job done.

The thing that is a mystery to me is why it is doing a full post back in the first place.I have everything working perfectly it's just the damned blink!

Thanks ... Ed


I have just had a similar situation myself whereby a full postback was occuring whenever I called __doPostBack. Trick is that you have to specifiy the actual client ID in the EventTarget parameter

i.e. _doPostBack('', ''); will NOT work where as _doPostBack('ctl00_textBox1', ''); WILL work. Obviously thats just an example so replace ctl00_textBox1 with your actual clientID value

So my code became:

textJobRef.Attributes.Add("onkeyup","javascript:setTimeout('__doPostBack(\'" + textJobRef.ClientID +"\', \'\')', 0)")

I dont think the timeout is required, but .NET does it so it must be for a reason! :)

Saturday, March 24, 2012

CalenderExtender in frameset problem

I have created an AJAX webpage which has been placed inside a HTML frameset(intranet at work). Outside the frameset, the calender extender works fine but inside the frameset I get a javascript permissions error. Anyone else had this problem?

Thanks,

Steve

Hi Stevedale,

I think your problem is a caused by Frameset + javascript rather than AJAX. First , you should check whether they are in different domains. Then please remove the interactions between the two Frameset. CalendarExtender is generated by a bunch of javascript. Here are two wonderful links(Link1,Link2);

If all these don't work, please feel free to let me know. And a tiny repro is preferred.

Best regards,

Jonathan

Calender Extender

HI All,

Am having a Calendar Extender inside a FormView and Formview is Inside UpdatePanel.
Problem am facing is that Calendar Comes Messy when it get activated. I tried CssClass but its not working.

Any Solution?

Hi Barrysuku,

To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Best regards,

Jonathan

this is a common issue that has a workaround on codeplex...I dont remember the link but all you need to do is put another calendarextender in your updatepanel and hide it via css


HI Jonathan,

I was able to solve that problem what i did is i added css class for CalenderExtender and its working fine now.

Now am having two issues if you can solve those for me.

First is how dela with FileUpload inside Updatepanel as am not getting filename.But when in scriptManager if i disable EnablepartialRendering to false then it works.Temporary am doing this.

Second how to load TreeView with ObjectDataSource or DataSet

Thanks

Regards

Barry


Hi Barrysuku,

In this thread, we are mainly discussing aboutCalenderExtender ,as indicated by the first post and the title.

Since your new question is not directly related to the original issue, it would be best if you open up a new thread for the new question. In this way, our discussion here will not deviate too much from the original issue. This will make answer searching in the forum easier and be beneficial to other community members as well.

Thank you for your understanding.

Best regards,

Jonathan

CalendarPopup not showing up over PopupControlExtender

I have a panel that is popped up via a PopupControlExtender and inside that panel I have a CalendarExtender that pops up but it is NOT showing up over top of the PopupControlExtender that is already popped up...How can I force the CalendarExtender to pop up over everything?

Thanks, Greg

I got the calendarExtender to work after I took it out of being contained in a UserControl... There must be something buggy with the CalendarExtedner being in a UserControl??

CalendarExtenter in a modal popup shows transparent

Hello,

i try to use a calendar extender inside a panle that is shown as a modal dialog using a modal popup extender. When the calendar pops up the displayed caledar is shown transparent (it has no background) and no animations are shown when switching between months.

Using the same outside a modal popup shows the calendar as usual.

Is a caledarextender not supposed to be used inside a modal popup?

Thanks in advance,

Ralf

This sounds like an issue we were having.

When you run the page, check the HTML source for a tag that looks like this:

<link href="http://links.10026.com/?link=/.../WebResource.axd?d=..." type="text/css" rel="stylesheet" /
(There should be alot of characters following the "d=")

If there is no reference made to WebResource, try putting another CalendarExtender control outside of the panel. This should force ASP.NET to add the reference.

Let me know what happens,
FB


I've looked at over a dozen suggestions to fix this issue. Finally you have the one that works. You are great! Thanks!

Wednesday, March 21, 2012

CalendarExtender with a ModalPopupExtender and missing weekdays

Hi

I am trying to use a CalendarExtender inside a Panel being shown as a ModalPopup. The functionality is fine , however the calendar has cropped two days of it the week of a week meaning that I am only seeing fron Sunday till Thursday. How am I to fix this or work around it ?

<asp:LinkButton ID="LinkButton1" runat="server">Godkend</asp:LinkButton>
<cc1:ModalPopupExtender ID="ModalPopupExtender1" BackgroundCssClass="modalBackground" CancelControlID="Button2" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1">
</cc1:ModalPopupExtender>
<asp:Panel ID="Panel1" runat="server" style="display:none">
<div >
<fieldset>
<legend>Detajler</legend>
<asp:RadioButtonList ID="RadioButtonList2" runat="server">
<asp:ListItem Value="0" Selected="True">Alle</asp:ListItem>
<asp:ListItem Value="1" >Valgte</asp:ListItem>
</asp:RadioButtonList>


<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Value="2" Selected="True">Godkendt</asp:ListItem>
<asp:ListItem Value="1">Afvist</asp:ListItem>
<asp:ListItem Value="0">Afventer</asp:ListItem>
</asp:RadioButtonList>
<asp:Label ID="Label4" runat="server" Text="Dato"></asp:Label><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox2" >
</cc1:CalendarExtender>
</fieldset>
<div>
<asp:Button ID="Button1" runat="server" Text="Ok" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" Text="Cancel" />
</div>
</div>
</asp:Panel>

Regards

I copied your code and it worked just fine for me. What timezone are you in?


I copied your code and it worked just fine for me. What timezone are you in?


I copied your code and it worked just fine for me. What timezone are you in?

I

I copied your code and it worked just fine for me. What timezone are you in?

I know

I copied your code and it worked just fine for me. What timezone are you in?


...


DisturbedBuddha:

I copied your code and it worked just fine for me. What timezone are you in?

I am in CET +1h. I can see others having experienced this issue also. They have been able to work around with some CSS tricks , but I have not been able to.

http://forums.asp.net/p/1089990/1642856.aspx

CalendarExtender Render Issues when Placed Inside Wizard Control

I'm using the CalendarExtender within the 3rd step of a Wizard Control. While developing the WizardStep, I would run the app (from that step) and the CalendarExtender controls render correctly. After completing development, I appropriately reset the Wizard Control to deploy from the Start WizardStep. But, the CalendarExtender does not render correctly when running the app from any step prior to the step that contains the CalendarExtender.

CORRECT RENDERING
Correct

INCORRECT RENDERING

Thanks,

-Dave

Many people have had this issue it has to do if the calender control is in a hidden update panel. see this page for a workaroundhttp://forums.asp.net/thread/1590343.aspx

AjaxButter


Clumsy...but it worked.

Thanks,

-Dave