Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Wednesday, March 28, 2012

UpdateProgress panel positioning

I have a page that has a datagrid that can be quite long. I don't want to page it so a user sometimes scrolls down and then clicks a button in the grid.

The issue is that the updateprogress image is up at the top of the page and if a user scrolls and then clicks in the grid they don't see the progress image because it is up top.

Is there a way to put the updateprogress panel where the user clicked instead of up top in a set position all the time?

Hi,

You can set the position of the updateprogress image via javascript according to the button's position.

Thanks

Updating a DataList with UpdatePanel

I've been trying to update my DataList with UpdatePanel but it's not working.

What I have is a text field for a user to enter comments and a save button, along with a DataList control all in an UpdatePanel.

Data is being saved on the table when the save button is clicked but the DataList is not updated unless I refresh the browser. What am I doing wrong?

Here is my ASP code:

 <asp:UpdatePanel ID="UpdatePanel3" runat="server"> <ContentTemplate> <asp:Panel ID="PanelCommentBody" runat="server" CssClass="collapsePanel" Width="451px"><br /> <asp:TextBox ID="txtComments" runat="server" Height="45px" TextMode="MultiLine" Width="412px" ValidationGroup="cmnts" ></asp:TextBox><br /> <asp:Label ID="lblComment" runat="server" Text="" Font-Size="Small"></asp:Label> <asp:RequiredFieldValidator ID="RFVComments" runat="server" ErrorMessage="Please enter comment." ValidationGroup="cmnts" ControlToValidate="txtComments" Font-Size="Small" Width="154px"></asp:RequiredFieldValidator> <asp:Button ID="bttnPostComment" runat="server" Text="Post Comment" OnClick="bttnPostComment_Click" ValidationGroup="cmnts" Width="122px" /> <asp:Button ID="bttnDiscard" runat="server" Text="Discard" OnClick="bttnDiscard_Click" CausesValidation="false" /> </asp:Panel> <cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender2" runat="server" CollapseControlID="closeComment" ExpandControlID="closeComment" TargetControlID="PanelCommentBody" Collapsed="true" SuppressPostBack="true"> </cc1:CollapsiblePanelExtender> <asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource1" Width="307px" Font-Size="Small"> <ItemTemplate> <strong>From: <a href="../Default.aspx?urnm=<%# Eval("UserName")%>"><asp:Label ID="FromLabel" runat="server" Font-Size="Small" Text='<%# Eval("UserName")%>'></asp:Label></a></strong> | Date Posted: <asp:Label ID="DateAddedLabel" runat="server" Text='<%# Eval("DateAdded", "{0:MMM dd, yy}")%>'></asp:Label><br /> <asp:Label ID="CommentLabel" runat="server" Text='<%# Eval("Comment")%>'></asp:Label><br /> <br /> </ItemTemplate> </asp:DataList><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MyDB%>" SelectCommand="SELECT [UserName], [Comment], [DateAdded] FROM [Comments] WHERE ([CL_Id] = @dotnet.itags.org.CL_Id) ORDER BY [DateAdded] DESC"> <SelectParameters> <asp:Parameter DefaultValue="1" Name="CL_Id" Type="String" /> </SelectParameters> </asp:SqlDataSource> </ContentTemplate> </asp:UpdatePanel>

Here is my Code Behind for the save button:

protected void bttnPostComment_Click(object sender, EventArgs e)
{
string flname = Request.QueryString["filename"];
flname = flname.Substring(0, flname.Length - 4);

if (User.Identity.IsAuthenticated)
{
MembershipUser myObject = Membership.GetUser();
string usrid = myObject.ProviderUserKey.ToString();
string usrname = User.Identity.Name;
string cmmnt1 = txtComments.Text;
string connStr = ConfigurationManager.ConnectionStrings["MyDB"].ConnectionString;
SqlConnection cnn = new SqlConnection(connStr);
SqlCommand cmd = new SqlCommand("INSERT INTO Comments (CL_Id, UserId, UserName, Comment) VALUES ('" + flname + "', '" + usrid + "', '" + usrname + "', '" + cmmnt1 +"')", cnn);
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
}
else
{
lblComment.Text = "You need to login to make comments";
}
}

----------

Thanks in advance,

Louis

1. Make UpdatePanel UpdateMode="Conditional"

2. after cnn.close(); write UpdatePanel3.Update()


Thanks siva sakki, I tried your suggestion but it still doesn't work.

What else can I try?

Louis


Updating a DataList with UpdatePanel

On Page_Load event, register DataList control

protected void Page_Load()
{
ScriptManager1.RegisterAsyncPostBackControl(DataList1);

DataList1.DataSource = this.SqlDataSource1;
DataList1.DataBind();
}


Thanks chetan, your suggestion might work. My problem is that I have the ScriptManger1 in the master page.

How can I reference this the way you have specified above?

Thank you,

Louis


I have tried the following to reference the the ScriptManger from content panel code behind:

ScriptManager.GetCurrent(this.Page).RegisterAsyncPostBackControl(DataList1);

is this the correct way of doing it? If it is my UpdatePanel still not updating. I have also removed this two lines:

//DataList1.DataSource = this.SqlDataSource1;
//DataList1.DataBind();

It is giving me this error:

Both DataSource and DataSourceID are defined on 'DataList1'. Remove one definition.

Do I need this two lines for it to work?

I am pulling my hair on this one.

Please help. Thanks again.

Louis


If you go back to the original code you submitted and add DataList1.DataBind() at the end of the button routine, you would probably achieve the results you want.

There is nothing to cause the DataList to rebind after the button event.

If you simply delete the UpdatePanel from the page, your code would not work either. As a rule, if doesn't work without Ajax, it won't work with it. The DataBinding event for the DataList has to run on the postback.


wrayx1 that did the trick.

Thank you soooo much!!!

Louis


Just do withDataList1.DataBind();

Let me know if this helps you


Okay, I have a similar question about updating using DataList. Will someone give me a hand on this. Here's what I have.

1<asp:ScriptManager ID="ScriptManager1" runat="server">2 </asp:ScriptManager>3<%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">4 <ContentTemplate>--%>5 <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True">6 <asp:ListItem Value="True">Approved</asp:ListItem>7 <asp:ListItem Value="False" Selected="True">Not Approved</asp:ListItem>8 </asp:RadioButtonList>9 <asp:SqlDataSource ID="sqlApproval" runat="server" ConnectionString="<%$ ConnectionStrings:myConnStr%>"10 SelectCommand="SELECT [frstName], [lstName], [dvlID], [mdlName], [mdnName], [degree1], [degree2], [year1], [year2], [sp_frstName], [sp_lstName], [sp_year1], [sp_year2], [sp_mdlName], [sp_mdnName], [sp_degree1], [sp_degree2], [approval] FROM [dvlStory] WHERE ([approval] = @.approval)"11 DeleteCommand="DELETE FROM [dvlStory] WHERE [dvlID] = @.dvlID"12 InsertCommand="INSERT INTO [dvlStory] ([frstName], [lstName], [mdlName], [mdnName], [degree1], [degree2], [year1], [year2], [sp_frstName], [sp_lstName], [sp_year1], [sp_year2], [sp_mdlName], [sp_mdnName], [sp_degree1], [sp_degree2], [approval]) VALUES (@.frstName, @.lstName, @.mdlName, @.mdnName, @.degree1, @.degree2, @.year1, @.year2, @.sp_frstName, @.sp_lstName, @.sp_year1, @.sp_year2, @.sp_mdlName, @.sp_mdnName, @.sp_degree1, @.sp_degree2, @.approval)"13 UpdateCommand="UPDATE [dvlStory] SET [frstName] = @.frstName, [lstName] = @.lstName, [mdlName] = @.mdlName, [mdnName] = @.mdnName, [degree1] = @.degree1, [degree2] = @.degree2, [year1] = @.year1, [year2] = @.year2, [sp_frstName] = @.sp_frstName, [sp_lstName] = @.sp_lstName, [sp_year1] = @.sp_year1, [sp_year2] = @.sp_year2, [sp_mdlName] = @.sp_mdlName, [sp_mdnName] = @.sp_mdnName, [sp_degree1] = @.sp_degree1, [sp_degree2] = @.sp_degree2, [approval] = @.approval WHERE [dvlID] = @.dvlID">14 <SelectParameters>15 <asp:ControlParameter ControlID="RadioButtonList1" Name="approval" PropertyName="SelectedValue"16 Type="Boolean" />17 </SelectParameters>18 <DeleteParameters>19 <asp:Parameter Name="dvlID" Type="Int32" />20 </DeleteParameters>21 <UpdateParameters>22 <asp:Parameter Name="frstName" Type="String" />23 <asp:Parameter Name="lstName" Type="String" />24 <asp:Parameter Name="mdlName" Type="String" />25 <asp:Parameter Name="mdnName" Type="String" />26 <asp:Parameter Name="degree1" Type="String" />27 <asp:Parameter Name="degree2" Type="String" />28 <asp:Parameter Name="year1" Type="Int32" />29 <asp:Parameter Name="year2" Type="Int32" />30 <asp:Parameter Name="sp_frstName" Type="String" />31 <asp:Parameter Name="sp_lstName" Type="String" />32 <asp:Parameter Name="sp_year1" Type="Int32" />33 <asp:Parameter Name="sp_year2" Type="Int32" />34 <asp:Parameter Name="sp_mdlName" Type="String" />35 <asp:Parameter Name="sp_mdnName" Type="String" />36 <asp:Parameter Name="sp_degree1" Type="String" />37 <asp:Parameter Name="sp_degree2" Type="String" />38 <asp:Parameter Name="approval" Type="Boolean" />39 <asp:Parameter Name="dvlID" Type="Int32" />40 </UpdateParameters>41 <InsertParameters>42 <asp:Parameter Name="frstName" Type="String" />43 <asp:Parameter Name="lstName" Type="String" />44 <asp:Parameter Name="mdlName" Type="String" />45 <asp:Parameter Name="mdnName" Type="String" />46 <asp:Parameter Name="degree1" Type="String" />47 <asp:Parameter Name="degree2" Type="String" />48 <asp:Parameter Name="year1" Type="Int32" />49 <asp:Parameter Name="year2" Type="Int32" />50 <asp:Parameter Name="sp_frstName" Type="String" />51 <asp:Parameter Name="sp_lstName" Type="String" />52 <asp:Parameter Name="sp_year1" Type="Int32" />53 <asp:Parameter Name="sp_year2" Type="Int32" />54 <asp:Parameter Name="sp_mdlName" Type="String" />55 <asp:Parameter Name="sp_mdnName" Type="String" />56 <asp:Parameter Name="sp_degree1" Type="String" />57 <asp:Parameter Name="sp_degree2" Type="String" />58 <asp:Parameter Name="approval" Type="Boolean" />59 </InsertParameters>60 </asp:SqlDataSource>61 <br />62 <asp:DataList ID="dltApproval" runat="server" BackColor="White" BorderColor="#999999"63 BorderStyle="None" BorderWidth="1px" CellPadding="3"64 GridLines="Vertical" RepeatColumns="3" RepeatDirection="Horizontal" Width="700px" DataSourceID="sqlApproval">65 <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />66 <SelectedItemStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />67 <ItemTemplate>68 <table border="0" cellpadding="2" cellspacing="0">69 <tr>70 <td>71 <asp:Label ID="frstNameLabel" runat="server" Text='<%# loadStory()%>'></asp:Label>72 </td>73 <td>74 <asp:CheckBox ID="chbApproval" runat="server" Checked='<%# Bind("approval")%>' />75 </td>76 </tr>77 </table>78 </ItemTemplate>79 <AlternatingItemStyle BackColor="Gainsboro" />80 <ItemStyle BackColor="#EEEEEE" ForeColor="Black" />81 <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />82 </asp:DataList>83<%-- </ContentTemplate>84 </asp:UpdatePanel>--%>85 <table border="0" cellpadding="5" cellspacing="0" width="700">86 <tr>87 <td style="width: 100px; text-align: center">88 <asp:Button ID="btnUpdate" runat="server" OnClick="btnUpdate_Click" Text="Update" /></td>89 <td style="width: 100px; text-align: center">90 <asp:Button ID="btnFinish" runat="server" OnClick="btnFinish_Click" Text="Finish" /></td>91 </tr>92 <>  

And here's the code behind:

1protected void Page_Load(object sender, EventArgs e)2 {34 }5protected string loadStory()6 {7//load the data in here and display to the lable control8return strInfoHolder.ToString() ;9 }10protected void btnUpdate_Click(object sender, EventArgs e)11 {12 sqlApproval.Update();13 dltApproval.DataBind();14 }15protected void btnFinish_Click(object sender, EventArgs e)16 {17 Response.Redirect("~/Admin/");18 }

The problem I have is that it's not updating. At the moment, I disabled the AJAX UpdatePanel to figure out the udpate first. All I wanted is to update the Approval checkbox to the sqlDataSource control. Noticed I used Bind instead of Eval for the checkbox control that way I was hoping that once I called the sqlApproval.Update() method, the approval checkbox will automatically update the database field. However, that is not so. Any help is appreciated.

Monday, March 26, 2012

Updating multiple controls

I have an asp.net web site. I have many text boxes, drop downs and check boxes that need to be populated based on user input. I have a main text box for them to put in an ID number and a button to run my code. The problem is that the text boxes and check boxes are all over the form so I can't group them in one update panel.

Also, some of the check boxes, drop downs and text boxes can change the data in other controls based on user input. This causes so many post backs under normal conditions. If I put everything in an update panel, isn't that still going to cause just as many post backs?

Putting the whole page in one UpdatePanel will cause pretty much the same amount of data to be sent back to the server (the whole viewstate is always sent) and by the sounds of it pretty much the same amount of data comin back. It would reduce network traffic a bit and get rid of the screen flicker though.

You really need to put just the bits that update in multiple UpdatePanels, they will all get updated when one does. However, I'd go one step further and set all of them to UpdateMode="Conditional" so you can only update the panels you need to when you need to.


Thank you. I looked into that a bit further and also watched a video on multiple update panels. I will try this, conditional updates and add triggers to the update panels. Thanks again.

updating only portion of a User control

Hi,

I Have an application Where I am dyanmically Loading User controls in a Main Page Content area(in an Update Panel)

And Each user control has its own update panel. for Example I have a List box and a text box and the Text box is in an update panel

And when the user select an item in the list box i need to update the text box upadate panel.

But the problem is since all these controls are in a user control and the user control loads in a place holder in an update panel in my main page.

To get the events of the user control child controls i need to load it again while asynchrounous post back

ie When user selects a menu item i am loading my user control into a place holder in an update panel in the main page.

and when the user clicks on the list box in my user control to get the selected index changed event i need to load the user control again

in my cs code. to the place holder . but i am only updating the text box in my user control. and so i placed that in an update panel.

but the problem is since my user control is inside an update panel in my main page the whole user control get refreshed.

I put the update mode of my main page update panel as conditional and when the user double clicks on the list box i load the user control in the palce holder so that i will get the events but i didn't update the main update panel. I did call only update for the update panel for the text box(which is in my user control)

but still my whole user controls get refeshed . Is there any solution for this

Thanks and regards

jereesh

Where the control that make posteback is located , is it inside your main update panel ?

if yes so you have to set "ChildrenAsTriggers" of your main update panel to false.

please let us know about your aspx code


HiI have a Main page where there is an update panel( where a place holder exists )which is made as conditionalAnd I have user controls(ascx) which are dynamically loaded into this update panel-into the place holder-(when user clicks on different menu items in main page. And inside each user Control there is an update panel where all child controls are placedand I may have update panels for individual controls in user controlfor example in one of my user control I have a list box and a text box and when i double click on the list box i need to change the text box value so i kept the text box inside an update Panel. but the problem is when i click on the list box in a user control if i need to get the event(selected indexchnaged) for that user control i need to load it again to the place holder in the cs file(Main.aspx.cs), ie if may user control name is search.ascxi am usong LoadControl method and adding it to the placeholder in my main page(this should happen each time when any postback occurs because of an event for a child control in the user control- then only i will get its events).I kept all update panel's update mode as conditional. and I will call only update for the update panelwhre my text box exists ( ie the update panel inside my user control). I only call Update for my main update panelonly when I need to load another user control ie when the user selects another menu item from the main page. mainupdatepanel -- Upadated only when new user control is to be loade usercontrolupdatepanel - Updated conditionally usercontrolchildcontrolUpdatepanel-- updates conditionallyThanks and Regards

Hi,

You have to set "ChildrenAsTriggers" of your main update panel to false.

Best Regards,

Updating the user interface on a web form BEFORE UpdatePanel finishes

Hello

does anyone know if it is possible to dynamically alter the contents of a control (e.g. a label) so that it updates BEFORE the UpdatePanel finishes its asynchronous operation? An example might be for a progress bar. I have a process which takes up to 5 minutes, but which generates an event as it progresses. I want to update a control each time this event gets triggered, but because I update the user interface in the async part, it doesnt do anything until it has completed.

For example imagine I have a button with an OnClick event inside an UpdatePanel, alongside a label in the UpdatePanel.
WHen I click the button, if I loop through one hundred objects, andwish to update the contents of the label as I do this (i.e. 'On itemnumber: x'), how is this done?

Thanks

Tom.

Have you tried calling the .Update() method on your update panel in the loop? That may or may not work.


Take a look at this:http://encosia.com/2007/10/03/easy-incremental-status-updates-for-long-requests/


I did try this within the asyn call, but nothing happens. I am assuming that whatever happens is built into a long string of javascript or suchlike which is not executed until completion.

That's right. Output buffering prevents anything along those lines from working. Using an iframe lets you work more interactively.

Updating UpdatePanel from User Control

Im havin problem s trying to update an UpdatePanel outside a User Control. This UP is suposed to update when i click a control in the UC.

I tried to add a trigger programmaticaly from when the UC loads.
Also tried the RegisterAsyncPostbackControl from the UC (this.Page.Master.FindControl("ScriptManager1").RegisterAsyncPo...)

none of this is working and i dont know hot to access the UC from the master page.
The user control is not contained in the master, is contained in an aspx using a master page.

The UpdatePanel is contained within the master page

Thanks

Show us some HTML and code behind would be helpful.


Hi,

You can use ScriptManager.GetCurrent(this) method in the content page to get reference to the ScriptManager instance. Try this:

ScriptManager.GetCurrent(this).RegisterAsyncPostBackControl(ucInstance);

Please note that UP doesn't support add trigger programatically.

Hope this helps.


Raymond Wen - MSFT:

Please note that UP doesn't support add trigger programatically.

Are you sure? The updatepanel trigger collection has an add method. I can add a trigger programatically to the updatepanel with that method, just tested.

AsyncPostBackTrigger t = new AsyncPostBackTrigger( );
t.ControlID = yourTriggerItem.ClientID;

yourUpdatePanel.Triggers.Add( t );


stmarti:

Raymond Wen - MSFT:

Please note that UP doesn't support add trigger programatically.

Are you sure? The updatepanel trigger collection has an add method. I can add a trigger programatically to the updatepanel with that method, just tested.

AsyncPostBackTrigger t = new AsyncPostBackTrigger( );
t.ControlID = yourTriggerItem.ClientID;

yourUpdatePanel.Triggers.Add( t );

http://ajax.asp.net/docs/mref/T_System_Web_UI_AsyncPostBackTrigger.aspx

Programmatically adding AsyncPostBackTrigger controls is not supported. Use the RegisterAsyncPostBackControl(Control) method of the ScriptManager control to programmatically register a postback control, and then call the Update() method of the UpdatePanel when the control posts back.

I haven't got the exact reason yet, but it's not recommended to do so. It may work, but can't guarantee anything.


Maybe it's supported/works, just not for any control on the page. /"The control that theAsyncPostBackTriggerreferences must be in the same naming container as the update panel forwhich it is a trigger. Triggers that are based on controls in othernaming containers are not supported...", and other restrictions applies./

I think it's safer to tell in the doc, that useRegisterAsyncPostBackControl(Control) and the update method, because it works for any postback control on the page.

Thanks for the clarification.


Thanks for your reply. This seem helpful.

I was wondering why im not getting the initialization script when the page is rendered to the browser:

Sys.WebForms.PageRequestManager._initialize('ctl00$Manager', document.getElementById('aspnetForm')); --- I took this from another application where partial rendering works just fine.

Im not getting this lines at the begining of the document.
Meybe this is the main issue. How can I get this lines to generated. I have compared both apps and the web.config has the same structure.

Thanks for your help


Raymond,

After using your code example those lines that were missing appeared in the rendered paged.

But still the page is doing a normal postback.


Here is a sample made according to your situation, please try it:

[Master]

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

<!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 Page_Load(object sender, EventArgs e)
{
Label1.Text = DateTime.Now.ToString();
}
</script
<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>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>

<asp:contentplaceholder id="ContentPlaceHolder1" runat="server">
</asp:contentplaceholder>
</div>
</form>
</body>
</html>

[Page]

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" Title="Untitled Page" %><%@. Register src="http://pics.10026.com/?src=WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %><asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <uc1:WebUserControl ID="WebUserControl1" runat="server" /></asp:Content>

[UserControl]

<%@. Control Language="C#" ClassName="WebUserControl" %><script runat="server"> protected void Button1_Click(object sender, EventArgs e) { UpdatePanel up = this.Page.Master.FindControl("UpdatePanel1") as UpdatePanel; up.Update(); } protected void Page_Load(object sender, EventArgs e) { ScriptManager sm = ScriptManager.GetCurrent(this.Page); sm.RegisterAsyncPostBackControl(Button1); UpdatePanel up = this.Page.Master.FindControl("UpdatePanel1") as UpdatePanel; up.UpdateMode = UpdatePanelUpdateMode.Conditional; }</script><asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />

Saturday, March 24, 2012

upgrading to Atlas 2.0

I upgraded a site to Atlas 2.0.
I now have a problem with an autoextender inside of a user control. In the user control, I am setting one of 6 textboxes visible depending upon the choice made in a dropdown list. Each textbox has an autoextender attatched to it. When the user starts typing, each autoextender calls it's own function in a web service and autofills the textbox.

This worked using 1.0 of Atlas with no errors

Now, When I browse to the page with the user control, I get the following error:
Assertion Failed: Could not find an HTML element with ID "CtlSearchLims1_txtStrain" for contorl of type "Sys.UI.Control" Break into Debugger?
Whether I click OK or cancel, nothing happens.

The ID of the Control is "CtlSearchLims1" and the first textbox on the control is txtStrain.
Every time I generate a postback I get the above mentioned message. For some reason, it is putting the control ID and the textbox ID together.

When I downloaded Atlas 2.0, I blew away the 1.0 download, so I either need to get this fixed or get a copy of the 1.0 download and go back to that version.

Thanks,

Faronwhere did you get atlas 2.0? since thereisn't even a 1.0 version. Atlas is still in beta and has a versionnumber like 0.0.0.0.0..0.0.0.0.1.2 or so.
So what do you mean? You upgraded from the March CTP to the April CTP?Or do you mean dat you upgraded from ASP.NET1.0 to ASP.NET 2.0?

I went from the previous version that has a Microsoft.Web.Atlas.dll in the bin folder of 167 kb (2/3/2006), to the latest version that has a Microsoft.Web.Atlas.dll of 1872 kb (4/6/2006).

I received no errors on the first version and it started failing when I moved to the current download of Atlas.

Faron


I went from the previous version (OF ATLAS) that has a Microsoft.Web.Atlas.dll in the bin folder of 167 kb (2/3/2006), to the latest version that has a Microsoft.Web.Atlas.dll of 1872 kb (4/6/2006).

Everything is on ASP.NET 2.0!

I received no errors on the first version and it started failing when I moved to the current download of Atlas.

Faron

Upload control in a Wizard in an Update Panel. How to add the trigger dynamically?

I have an update panel surrounding a Wizard control. One of the steps in that wizard is that the user can upload photos. So what I want to do is add a trigger to force a full postback on the upload step.

Is this at all possible? I'm having troubles obtaining the correct ControlID to add on the trigger...

ctafield:

I have an update panel surrounding a Wizard control. One of the steps in that wizard is that the user can upload photos. So what I want to do is add a trigger to force a full postback on the upload step.

Is this at all possible? I'm having troubles obtaining the correct ControlID to add on the trigger...

Hi.

FileUpload is not supported with ASP.NET AJAX .because that you cann't use it and you cann't find it with ControlID's!


Create a Button Control and set this as a PostBack trigger forupdatePanel. In the Button Click event save the file from File uploadcontrol.

anishdevasia:

Create a Button Control and set this as a PostBack trigger for updatePanel. In the Button Click event save the file from File upload control.

Thank you for the suggestion. I'll give it a go!

Uploading file during onchange

I try to upload file in server during user select file:

<inputid="iupload"runat="server" type="file"style="width:1px"/>
<inputtype="hidden"id="hdName"runat="server"/>

<scriptlanguage="javascript">
function Doo(){
document.getElementById('hdName').value = document.getElementById('iupload').value;// to check path
WebForm_DoCallback('__Page',document.getElementById('iupload').value,CallbackFunction,'context',null,false);returnfalse;
}
</script>

and on server side:

protectedvoid Page_Load(object sender, EventArgs e)
{
string argClientFunction ="";
string cScript = ClientScript.GetCallbackEventReference(this, argClientFunction,"CallbackFunction","'context'","null",false);
string f=@dotnet.itags.org."
javascript:Doo();";
iupload.Attributes.Add("onchange", f);

string scr ="<script language=javascript>";
scr +="function CallbackFunction(result, context)";
scr +="{";
scr +="document.getElementById('spUploaded').innerText += 'Done';";
scr +=" return false;";
scr +="}";
scr +="</script>";
RegisterStartupScript("scr" +this.ClientID, scr);

}


publicvoid UploadFile(string fileName)
{
// try to upload file to server
}
publicstring GetCallbackResult()
{
UploadFile(evArg);

evArg = String.Empty;

return evArg;
}
publicvoid RaiseCallbackEvent(string eventArgument)
{
evArg = eventArgument;
}

Problem occur in UploadFile(...): When I try to get iupload.PostedFile for file uploading it's null. I can get file name only.

How can I upload file normally without postback with onchange ?

I need upload file to server as Gmail or Yahoo Mail!

File uploads require a full postback. There has been a lot of talk on here about sites such as gmail that appear to asynchronously load a file. At this point, the only way that I have heard of this successfully implemented is by using IFrames and have another page that does the full postback, but doesn't look like it.


Thank you! I have heard about Iftame to upload files. Have you any information about this?


Not really... we haven't got into handling file uploads very often, and if we do, we would probably use the telerik fileupload control since we have the suite and I believe it handles very large files much better that the built in fileupload for asp.net. When I tested both of them, I was able to crash IIS with the built in control by trying to upload a dvd image because it seemed to check for the file size only after it had been processed through IIS, but the telerik control seemed to do that in pieces which didn't cause it to lock up.

Wednesday, March 21, 2012

Use "Hello World Using Client Script" in UserControl

Hi

I want to create a asp.net user control for dynamic date entering, and I'm trying to use the same approach as in the example:

 <form runat="server">
<div>
Search for
<input id="SearchKey" type="text" />
<input id="SearchButton" type="button"
value="Search"
onclick="DoSearch()" />
</div>
</form>
<hr style="width: 300px" />
<div>
<span id="Results"></span>
</div>
<script type="text/javascript"
function DoSearch()
{
var SrchElem = document.getElementById("SearchKey");
Samples.AspNet.HelloWorldService.HelloWorld(SrchElem.value,
OnRequestComplete);
}

function OnRequestComplete(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
}

</script>

The problem is if I use <input id=SearchKey> -tag for the result, then there will be problems if I use the same control multiple times on one page (the id is not unique, and the OnRequestComplete will update every <input>-tag with id=SearchKey). If I change it to <input id=SearchKey runat=server>, asp will render unique id's for the <input>, but then .getElementById() does not find "object".

I have done a "workaround" where I passes the object's Id to the Webservice, and returns it in an array together with the result, but I don't think this is "a great way". Is there any other solution? A better one?

function DoSearch(CallerId)
{
var SrchElem = document.getElementById(CallerId);
Samples.AspNet.HelloWorldService.HelloWorld(this.id, SrchElem.value,
OnRequestComplete);
}

function OnRequestComplete(result)
{

var objectId = result[0].toString();
var WebServiceResult = result[1].toString();
var RsltElem = document.getElementById(objectId);
RsltElem.innerHTML = result;
}

Regards

Lars K.

This is a common problem... if you use ASP.NET server IDs you need to reference the client ID in client script:

var Ctl = $('<%= SearchKey.ClientID %>');

will do the trick in finding the control reliably.

You also need to use this if use MasterPages or any contained control, so as a general rule this is the best way to reference server based page variables.

+++ Rick --

Use Ajax controls within web control

Is there any example that show how to write a custom web control (one that doesn't have aspx) and use Ajax controls ?

I have a user control consisting of a panel the modalpopupextender. I have a copy of the aspx and .cs file in all the sites. I want to turn it into a control so I can re-use it. How can I achive it?

Hi Thanhhuynh,

Basically, you can drag it into your customer control without doing any other special settings. Ajax Control Toolkits work depend on ScriptManager or ToolkitScriptManager. Please make sure that the ScriptManager should be located before the extender and inside a page there should be only one ScriptManager. To create customer control , here are two samples(sample1 andsample2).

I hope this help.

Best regards,

Jonathan


Thanks for answering.

Basically there are two type of controls I can create: web control and web user control. The former contains only code. There's no UI designer support where you can drag and drop different controls into it. You can to override the RenderXX() methods to create the look. The web user control has the UI part and the code behind and you can design right on the screen. But web user can only be used within the same web site. You have to copy the aspx and code-hind files to another web site source tree in order to re-use it.

So my question was let's say I create a new control, without VS UI designer how can I use the AJAX extender ?

Thanks


I believe the answer you are looking for is in this blog post by David Ebbo:http://blogs.msdn.com/davidebb/archive/2005/10/30/487160.aspx

Good luck,

Hanan Schwartzberg
---------------
http://www.lionsden.co.il