Showing posts with label create. Show all posts
Showing posts with label create. Show all posts

Wednesday, March 28, 2012

postback problem

i have asp.net web page,on page load i create a simple html table with fixed no of rows and no of columns and their names are determined dynamically.now i have few javascipt functions for adding a row to table,for adding another column to table and for removinga row from table.

also i have a asp:button on click of which a xml file is generated from the data filled in by user in the table.but as soon as i hit the asp button to generate xml all newley added rows and columns are deleated.Is it possible to call a server side function without posting the page back.

Yes, it is

take a look at this article about client scripts callbacks:

http://msdn.microsoft.com/msdnmag/issues/04/08/CuttingEdge/

Cheers,

Yani


hey went throught the article actually i mean new to all this so didnt get it completely some code help from ur side will be appriciated

actually i have a method on server side that accepts the html table parses it and writes the data of html table in a xml file.

and i want to call this method on click of a button and without postback.

thanx in advance

sandeep


Sorry man,

I haven't put the client scripts callbacks into practice yet too.

I was going to use them to create a dynamic progress bar, but then i've decided to use the ajax update panel.

It was much faster and cheaper.

Cheers,

Yani

Postback problem with dynamically added ModalPopupExtender

In my task i have to create ModalPopupExtender dynamically, and add an .ascx control to it. This is the code:

Test.aspx page:

<

asp:ScriptManagerProxyrunat="server"ID="proxy"/>

<

asp:UpdatePanelrunat="server"ID="ajaxPanel"RenderMode="Inline"UpdateMode="Conditional"><ContentTemplate><asp:Panelrunat="server"ID="panel"><asp:Buttonrunat="server"ID="btn2"Text="Show Control"OnClick="btn2_Click"/></asp:Panel>

<%

--<asp:Button runat="server" ID="btn1" Text="test1" OnClick="btn1_Click" />--%>

</ContentTemplate></asp:UpdatePanel>

test.ascx control:

<

asp:ScriptManagerProxyrunat="server"ID="proxy"/>

<

asp:UpdatePanelrunat="server"ID="ajaxPanel2"RenderMode="Inline"UpdateMode="Always"><ContentTemplate> <asp:Buttonrunat="server"ID="btnTest2"Text="test2"OnClick="btnTest2_Click"/></ContentTemplate></asp:UpdatePanel><asp:Buttonrunat="server"UseSubmitBehavior="false"ID="btnTest"Text="Close OK"OnClick="btnTest_Click"/><asp:Buttonrunat="server"UseSubmitBehavior="false"ID="btnTestClose"Text="Close"OnClick="btnTest_Click"/>

In aspx page:

protected

overridevoid OnInit(EventArgs e)

{

base.OnInit(e);Control c = LoadControl("~/test.ascx");

c.ID =

"customModalControl";Panel p =newPanel();

p.Width = 300;

p.Height = 200;

p.CssClass =

"modalPopup";

p.ID =

"modalPanel_";_modalPopup =newModalPopupExtender();

_modalPopup.ID =

"modalPopup";

_modalPopup.DropShadow =

true;

_modalPopup.BackgroundCssClass ="modalBackground";

_modalPopup.PopupControlID = p.ID;

_modalPopup.TargetControlID = btn2.ID;

Control c2 = c.FindControl("btnTest");

_modalPopup.OkControlID = c2.ClientID;

c2 = c.FindControl("btnTestClose");

_modalPopup.CancelControlID = c2.ClientID;

p.Controls.Add(c);

panel.Controls.Add(_modalPopup);

panel.Controls.Add(p);

}

protectedvoid btn1_Click(object sender,EventArgs e)

{

}

protectedvoid btn2_Click(object sender,EventArgs e)

{

_modalPopup.Show();

}

onInit event, i create ModalPopupExtender and a panel for ascx control. All works fine, but is one problemCrying, when i click btnTest2 on ModalPopup, rises postback for the page, but ascx control didn't receive btnTest2 _OnClick event. Maybe someone know where is a problem. Thank you.

Try to change change some of your codes to specify asynchronous post back.
<asp:UpdatePanel runat="server" ID="ajaxPanel2" RenderMode="Inline" UpdateMode="Always">
<ContentTemplate>
??????<asp:Button runat="server" ID="btnTest2" Text="test2" OnClick="btnTest2_Click"/>
</ContentTemplate>
<triggers>
????<asp:AsyncPostBackTrigger ControlID="btnTest2" EventName="Click"/>
</triggers>

</asp:UpdatePanel>
Wish this can help you.

Postback sees TextChanged event while timer initiated the postback


Hi,

I have a challenge which I cannot seem to master and I hope that somebody already solved it.

Here is the setup to create the issue:

Place an updatepanel on a page, place a timer control inside (or outside with a trigger section for the panel), set the interval to 3000 or so and enable the timer.

Then place a TextBox on the page and add some code to the TextChanged event.

Now start the page..

Type some text in the textbox but don't press enter, when the timer fires you will find that the TextChanged event comes in through the postback.

I think I have tried everything, partialrendering to true, updatemode to conditional, childelementsastriggers to false and so on...

I need the text entered in the textbox to stay as it is until the moment the user presses enter, while the update panel constantly refreshes a datagrid.

Does anybody have a solution? Would I need to use a javascript timer which updates the datagrid? would that prevent a postback?

Please help...

Thanks

Is the textbox inside the updatepanel?

If your expecting the user to hit enter, presumably that triggers a click event for a button. Why not read/process the textbox's value as part of the button's click event and avoid TextChanged altogether?


Inside or outside renders the same problem.

The thing is that when a user enters some text in the textbox but is not finished typing yet, the timer causes a postback which in turn results in the TextChanged event, but the user is not ready to post yet.


Yeah i'd say this is by design and theres nothing you can do about it. Modify your approach so it doesn't make use of the TextChanged event (as i suggested in previous post).


If you can put the DataGrid and TextBox in separate UpdatePanels, that would begin to solve the problem.


Ha, I won't sacrefice design over some "feature". I won't believe that this behaviour is by design and if it is then there must be a way to intercept the event..

Hmm... I may have solved my own problem.

P.S. the TextChanged event is needed as we are using barcode scanners which add a carriage return to the end of the text stream which triggers the TextChanged event just nicely. The user should also be able to enter some code without hitting a button as confirmation..

Thanks,

Wouter


I'm not sure how multiple UpdatePanels would change your design, since you didn't post any sample code.

You may want to take a closer look at how UpdatePanels work. What you're describing is the inevitable consequence of putting a timer on an UpdatePanel that contains data entry fields.

Saturday, March 24, 2012

Problem converting inserted html to ajax client control

Hi,

im inserting a htmltable which is returned by a webservice into a div container.
My problem is that i am not able to create a client control out of this htmltable (or its child elements)
although its inserted properly. It seems that inserted HTML is not available in the dom right after insertion.
Any suggestions?

thank you!
spoekes

Try to post some codes and give us some brief description here.We will try our best to help you.

Problem Creating New Control toolkit

I have a problem that I am just about to give up on (so any help might save my sanity)

If I create a completely new Atlas project and use the default names I can create a new control add it to my test project and run it. However, if I right click and add a new item (of type Atlas control) no matter what I do to this (including inspecting the files line by line) I cannot get it to work. It fails with unrecognised tag and then my namespace and control when loading the page in IE. Now clearly it is not too much wrong as I can drag the control from the toolkit and it will check my tags to see if they are allowed. I can also use the properties i have created and they appear as correct extenders on the correct objects. It appears to be just the final link between the control and the browser.

When I debug I come back to the routine

Sys.TypeDescriptor.getType = function(tagPrefix, tagName) {
var type = null;
if (Sys.TypeDescriptor._registeredTags) {
var tagNameTable = Sys.TypeDescriptor._registeredTags[tagPrefix];
if (tagNameTable) {
type = tagNameTable[tagName];
}
}
debug.assert(type, String.format("Unrecognized tag {0}:{1}", tagPrefix, tagName));
return type;
}

The array_registeredTags contains (script, toolkit, atlascontroltoolkit) Should I see my namespace in here too?

I have gone through my code and created several projects and I cant figure it out.

Any help would be appreciated.

Thanks

Geoff

Hi Geoff,

You should check outFAQ Item #5. I'm guessing your script isn't an embedded resource.

Thanks,
Ted

Wednesday, March 21, 2012

Problem on creating popup window with ajax

Hi ,

I want to create a popup window when i select ' add new' in dropdown list. I am using javascript for opening popup window and to bind dropdown list details im using AJAX. The problem here is popup window is not opening with ajax. Without ajax it is opening.Why? ( Iam using asp.net2.0 version)

Thanks.

Make sure you're using ScriptManager.RegisterStartupScript to register your popup script. Take a look here for an example: http://encosia.com/index.php/2007/06/19/the-easiest-way-to-break-aspnet-ajax-pages/


Hi,

I try to insert the bellow method insted of responce.write()

Page.ClientScript.RegisterClientScriptBlock("","","") in my code, But it showing an error of parameter 'type' I used type=me.gettype() method.

Any idea how to pass parameters?

Thanks,

Aswath.


Make sure you use the ScriptManager method, not the ClientScript one, if you want to use it in a partial postback.


Hi all,

I can able to create popup window as well as closing it autometically, But the problem is after closing popup window i want to display the value in parent window.Can anybody help me...? In popup window one dropdown list was there iam storing that value(what i entered in dropdown) in database after that window is closing autometically.Now i want to display that value what i stored in database in my parent window's dropdown list.

plz help me ....

Aswath.