Hi All,
i used the idea of using the BinaryImageColumn for loading, inserting and editing images stored in a database with RadGrid and ajax disabled only when click the insert or edit button of the edit form like the demo on the floowing link
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultcs.aspx?product=grid
but i noticed in this demo, when the user click more than one on the insert button, the file will be saved more than one time!!!!
how can i solve this problem????
any idea to work around????
Thanks in Advanced...
Asa'ad...
i used the idea of using the BinaryImageColumn for loading, inserting and editing images stored in a database with RadGrid and ajax disabled only when click the insert or edit button of the edit form like the demo on the floowing link
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultcs.aspx?product=grid
but i noticed in this demo, when the user click more than one on the insert button, the file will be saved more than one time!!!!
how can i solve this problem????
any idea to work around????
Thanks in Advanced...
Asa'ad...
14 Answers, 1 is accepted
0
Hello Asa'ad,
To achieve your goal, you can set RequestQueueSize property in RadAjaxPanel to "1".
I hope this helps.
Best wishes,
Milena
the Telerik team
To achieve your goal, you can set RequestQueueSize property in RadAjaxPanel to "1".
I hope this helps.
Best wishes,
Milena
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Asa'ad
Top achievements
Rank 1
answered on 22 Nov 2011, 08:54 AM
Hi Milena
this solution has solved the problem just in case the file size is small...but in case the file size is big, user when click the button multiple time it will save the file more than once???!!!!
hope yon can help me..this is very important issue...
thanks
Asa'ad...
this solution has solved the problem just in case the file size is small...but in case the file size is big, user when click the button multiple time it will save the file more than once???!!!!
hope yon can help me..this is very important issue...
thanks
Asa'ad...
0

Asa'ad
Top achievements
Rank 1
answered on 24 Nov 2011, 07:46 AM
Any Help????
thanks
Asa'ad...
thanks
Asa'ad...
0
Hello Asa'ad,
Generally speaking you have to ensure that once clicked, the button will be disabled. This can be achieved using several approaches. For example you can add some kind of a modal control that would appear in front of the button so that it can not be clicked. This option could be achieved by adding RadAjaxLoadingPanel
I hope this helps.
Kind regards,
Milena
the Telerik team
Generally speaking you have to ensure that once clicked, the button will be disabled. This can be achieved using several approaches. For example you can add some kind of a modal control that would appear in front of the button so that it can not be clicked. This option could be achieved by adding RadAjaxLoadingPanel
to your page. Another option is to add a client side handler to the button that once clicked would make it disabled / readonly.I hope this helps.
Kind regards,
Milena
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Asa'ad
Top achievements
Rank 1
answered on 24 Nov 2011, 11:19 AM
Hi Milena
there is an already exists RadAjaxLoadingPanel that is associated with the RadAjaxPanel, but since the Ajax request is disabled while doing the insert or update operation...it will not be show!!!!
for the other option, how can i do it since i am using the edit form of the radgrid...how can i access the update, edit button of this form from javascript or from the code behind???
thanks
Asa'ad...
there is an already exists RadAjaxLoadingPanel that is associated with the RadAjaxPanel, but since the Ajax request is disabled while doing the insert or update operation...it will not be show!!!!
for the other option, how can i do it since i am using the edit form of the radgrid...how can i access the update, edit button of this form from javascript or from the code behind???
thanks
Asa'ad...
0
Hi Asa'ad,
Another option for achieving your goal is to hide the update button after it is clicked. You can see how to access and hide it in the code below:
I hope this helps.
Kind regards,
Milena
the Telerik team
Another option for achieving your goal is to hide the update button after it is clicked. You can see how to access and hide it in the code below:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridBinaryImageColumnEditor editor = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("Upload") as GridBinaryImageColumnEditor;
TableCell cell = (TableCell)editor.RadUploadControl.Parent;
CustomValidator validator = new CustomValidator();
validator.ErrorMessage = "Please select file to be uploaded";
validator.ClientValidationFunction = "validateRadUpload";
validator.Display = ValidatorDisplay.Dynamic;
cell.Controls.Add(validator);
GridEditFormItem item = e.Item as GridEditFormItem;
string buttonId = (item.FindControl("CancelButton") as Button).ClientID;
string script = String.Format("document.getElementById('{0}'){1}", buttonId, ".addEventListener('click', MyClick, false);");
RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "DisableButton", script, true);
}
}
function MyClick() {
this.style.visibility = "hidden";
}
I hope this helps.
Kind regards,
Milena
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Asa'ad
Top achievements
Rank 1
answered on 27 Nov 2011, 09:56 AM
Hi Melina,
t ried your code, but i give me the error saying that the button is null object....
so i changed it as the below
but it also goves me an error saying the object doesn't support this property or method!!!
Please Help....
t ried your code, but i give me the error saying that the button is null object....
so i changed it as the below
if ((e.Item is GridEditableItem) && (!e.Item.OwnerTableView.IsItemInserted) && (e.Item.IsInEditMode))
{
GridEditFormItem editItem = (GridEditFormItem)e.Item;
ImageButton updBtn = (ImageButton)editItem.FindControl("UpdateButton");
string buttonId = updBtn.ClientID;
string script = String.Format("document.getElementById('{0}'){1}", buttonId, ".addEventListener('click', MyClick, false);");
RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "DisableButton", script, true);
}
if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
{
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
ImageButton insertBtn1 = (ImageButton)insertItem.FindControl("PerformInsertButton");
string buttonId = insertBtn1.ClientID;
string script = String.Format("document.getElementById('{0}'){1}", buttonId, ".addEventListener('click', MyClick, false);");
RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "DisableButton", script, true);
}
but it also goves me an error saying the object doesn't support this property or method!!!
Please Help....
0
Hello Asa'ad,
In order to implement the desired functionality you need to make some additional changes to your code. I would suggest you to remove the following code from the ItemCreated event and add it to the ItemDataBound event as it is shown in the code below:
Please, consider that the addEventListener method does not work in Internet Explorer version 9. For earlier Internet Explorer versions, use the attachEvent method to register the event handler.
Note that the above solution is one way for implement the desired custom functionality, and it might need further adjustment.
Greetings,
Milena
the Telerik team
In order to implement the desired functionality you need to make some additional changes to your code. I would suggest you to remove the following code from the ItemCreated event and add it to the ItemDataBound event as it is shown in the code below:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridBinaryImageColumnEditor editor = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("Upload") as GridBinaryImageColumnEditor;
RadAjaxPanel1.ResponseScripts.Add(string.Format("window['UploadId'] = '{0}';", editor.RadUploadControl.ClientID));
GridEditFormItem item = e.Item as GridEditFormItem;
string buttonId = (item.FindControl("UpdateButton") as ImageButton).ClientID;
string script = String.Format("document.getElementById('{0}'){1}", buttonId, ".addEventListener('click', MyClick, false);");
RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "DisableButton", script, true);
}
}Please, consider that the addEventListener method does not work in Internet Explorer version 9. For earlier Internet Explorer versions, use the attachEvent method to register the event handler.
Note that the above solution is one way for implement the desired custom functionality, and it might need further adjustment.
Greetings,
Milena
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Asa'ad
Top achievements
Rank 1
answered on 30 Nov 2011, 11:58 AM
Hi Milena again...
thanks for you help....
i tried the solution you suggested and after changing the addEventListener to use the attachEvent
the MyClick script is called but the button has not become hidden...it give an error saying 'style' is null or not an object
i tried another way;
by defining Click Event Handler to the insert image button;;;
and the event is called but i cannot change any propperty of the button except for the enabled...
but also with solution;;;user can click multiple time!!!!
i dont know what to do else!!!!
if you have any other suggestion i will be happy to know!!!!
Thanks
Asa'ad
thanks for you help....
i tried the solution you suggested and after changing the addEventListener to use the attachEvent
the MyClick script is called but the button has not become hidden...it give an error saying 'style' is null or not an object
if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
{
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
ImageButton insertBtn1 = (ImageButton)insertItem.FindControl("PerformInsertButton");
string buttonId = insertBtn1.ClientID;
string script = String.Format("document.getElementById('{0}'){1}", buttonId, ".attachEvent('onclick', function(){ MyClick();});");
RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "DisableButton", script, true);
RadAjaxManager1.ResponseScripts.Add(script);
}
i tried another way;
by defining Click Event Handler to the insert image button;;;
and the event is called but i cannot change any propperty of the button except for the enabled...
but also with solution;;;user can click multiple time!!!!
if (e.Item is GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
{
GridEditFormInsertItem insertItem = (GridEditFormInsertItem)e.Item;
ImageButton insertBtn1 = (ImageButton)insertItem.FindControl("PerformInsertButton");
insertBtn1.Click += new System.Web.UI.ImageClickEventHandler(insertClick);
}
protected void insertClick(object sender, ImageClickEventArgs e)
{
ImageButton btn = (ImageButton)sender;
btn.Enabled = false;
//btn.BackColor = System.Drawing.Color.Red;
//btn.Style["visibility"] = "hidden";
}
i dont know what to do else!!!!
if you have any other suggestion i will be happy to know!!!!
Thanks
Asa'ad
0
Accepted
Hi Asa'ad,
The following code is one of the ways, which you can use to overcome this problem.
Additionally, .attachEvent will work only in Internet Explorer. For any other browsers you should use .addEventListener and in order your page to be cross-browser you need to modify the code.
Please note, that is only one possible approach for overcoming your problem and might need further adjustments for your specific case.
I hope this helps.
Kind regards,
Milena
the Telerik team
The following code is one of the ways, which you can use to overcome this problem.
string script = String.Format("document.getElementById('{0}'){1}", buttonId, ".attachEvent('onclick', function(){MyClick('"+buttonId+"');});");
RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "DisableButton", script, true);
function MyClick(o) {
if (o) {
$get(o).style.visibility = "hidden";
}
}
Additionally, .attachEvent will work only in Internet Explorer. For any other browsers you should use .addEventListener and in order your page to be cross-browser you need to modify the code.
Please note, that is only one possible approach for overcoming your problem and might need further adjustments for your specific case.
I hope this helps.
Kind regards,
Milena
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0

Asa'ad
Top achievements
Rank 1
answered on 05 Dec 2011, 09:08 AM
Thank you Milena...
This has solved my problem :-)
Regarding the other browsers, our testing environment now includes Internet Explorer Only...
We may extends to the other browser in the future....
Many thanks again....
Best Regards
Asa'ad....
This has solved my problem :-)
Regarding the other browsers, our testing environment now includes Internet Explorer Only...
We may extends to the other browser in the future....
Many thanks again....
Best Regards
Asa'ad....
0

Asa'ad
Top achievements
Rank 1
answered on 05 Dec 2011, 02:10 PM
sorry and hi again...
when i do more testing,,,i found that if the edit from is not valid....the button becomes unvisible even if the the validation controls are triggered!!!
i tried to call the javascript from the click event of the insert button after checking if the Page.IsValid,,,
the script is called if it gives an error saying 'style' is null or not an object!!!!
i appreciate any idea....
thanks
when i do more testing,,,i found that if the edit from is not valid....the button becomes unvisible even if the the validation controls are triggered!!!
i tried to call the javascript from the click event of the insert button after checking if the Page.IsValid,,,
the script is called if it gives an error saying 'style' is null or not an object!!!!
i appreciate any idea....
thanks
0

Asa'ad
Top achievements
Rank 1
answered on 08 Dec 2011, 07:54 AM
any help please....
0
Hello Asa'ad,
Note that the approach we have been discussing was just for demonstration purposes and does not pretend to be the perfect one neither the only one. Please feel free to customize it so that your final result is achieved. For example you can add some javascript code that can find the RadUpload Client Object and by using its getFileInputs method verify whether its file Input element is empty. Based on that check, you can apply the custom code that disables the button.
I hope this helps.
All the best,
Martin
the Telerik team
Note that the approach we have been discussing was just for demonstration purposes and does not pretend to be the perfect one neither the only one. Please feel free to customize it so that your final result is achieved. For example you can add some javascript code that can find the RadUpload Client Object and by using its getFileInputs method verify whether its file Input element is empty. Based on that check, you can apply the custom code that disables the button.
I hope this helps.
All the best,
Martin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now