|
kupi93 wrote:
What does the demo mean? which demo?
I'm referring to the demo files (rsDemo.aspx, rsDemo.xml) that are part of the download. That page has a Submit button and shows how to address your problem.
Regards,
Alvaro
Explain to the mothers & fathers of American servicemen that may come home in body bags why their son or daughter have to give up their life?" -- Sean Hannity, 1999.
|
|
|
|
|
Hi~~
I have solved it in another stupid manner with javascript and hidden textbox contols.
Now I'll expain to you my solution.
In brief, I made my page post back the option values and selected value to the server.
And the server re-generates the postbacked options and sets selected value in pre-render method.
In user's eyes, the page is just refreshed, but in every rendering, the page has diferrent
options in a html source level.
first of all, I made the hidden textbox server-controls in my page as follows.
. // In *.aspx file...
.
.
<div style="DISPLAY: none; VISIBILITY: hidden">
<asp:textbox id="txtWCValue" runat="server" Width="72px"></asp:textbox>
<asp:textbox id="txtWCSelect" runat="server" Width="72px"></asp:textbox>
</div>
.
.
And I've made the javascript functions as follows.
. // In *.aspx file...
.
.
<script language="JavaScript">
function OnSelectedChange( strID )
{
var ddlS = document.getElementById( strID );
var strValue = ddlS.value;
if ( strID == 'ddlArea' )
{
window.status = 'Loading...';
RS.Execute( '../InquiryCondition.aspx', 'GetWCenterALL', strValue, UpdateWC );
}
else if ( strID == 'ddlWCenter' )
{
SaveSelect( strID, 'txtWCSelect' );
}
}
function UpdateWC( result )
{
RS.ReplaceOptions( document.getElementById( 'ddlWCenter' ), result );
document.getElementById( 'txtWCValue' ).value = result;
OnSelectedChange( 'ddlWCenter' );
window.status = "";
}
function SaveSelect( strDDL, strTextBox )
{
var ddlS = document.getElementById( strDDL );
var txtSelect = document.getElementById( strTextBox );
txtSelect.value = ddlS.options[ ddlS.selectedIndex ].value;
window.status = "";
}
function OnLoad()
{
OnSelectedChange( 'ddlArea' );
}
</script>
<script language="C#" runat="server">
/***********************************************************************
* Objective : method to set the attribute of body tag. It changes the
* event of "Onload" in body tag in according to the state of
* page(Initial request or postbacked)
* Param : object Source - event sender, not used
* EventArgs e - event argument, not used
* Return : void
***********************************************************************/
void Loading(object Source, EventArgs e)
{
if( !this.IsPostBack )
DailyProdByWC.Attributes["onload"] = "javascript:OnLoad();";
else
DailyProdByWC.Attributes["onload"] = "";
}
</script>
.
.
<BODY id="DailyProdByWC" text="#000000" bgColor="#eae9dc" leftMargin="0" topMargin="0" onload="Loading" rightMargin="0" runat="server">
.
.
< When the user load the page fist time, he/she needs to see default option values.
In body tag, C# script changes event handler of onload event in body tag with the state
of page.
( When the page is loaded first, it performs "OnLoad()" function of javascript. So he/she can
see default option values filled by remote script. when it's postbacked, c# script function
change its onload envent handler like this[ onload="" ] and doesn;t anything. So it can
retain its previous selected value. ) >
And every DropdownList control has its "OnChange" event handler as follows.
. // in codebehind of my page
.
.
private void DailyProdByWC_PreRender(object sender, System.EventArgs e)
{
this.ddlArea.Attributes.Add( "OnClick", "javascript:OnSelectedChange('ddlArea');" );
this.ddlWCenter.Attributes.Add( "OnClick", "javascript:OnSelectedChange('ddlWCenter');" );
.
.
.
When the user selects dropdownlist, "OnChange" event occurs and it calls its remote script fuction in "InquiryCondition.aspx.cs" as follows.
. // In "InquiryCondition.aspx.cs"
.
.
/***********************************************************************
* Objective : method to return the conditions of work centers
* Param : String strArea - Area ID
* Return : String - html values of conditions
***********************************************************************/
public String GetWCenterALL( String strArea )
{
DataSet ds = Session[ "INQUIRY_CONDITION" ] as DataSet;
if ( ds == null || ds.Tables.IndexOf( "SYS_WC" ) == -1 )
return "<option value=''>-- MES Error! --</option>";
StringBuilder result = new StringBuilder();
DataRow[] drs = ds.Tables[ "SYS_WC" ].Select( "AREA_ID='" + strArea + "'" );
if ( drs.Length > 1 )
result.Append( "<option value='-1'>ALL</option>" );
else
{
ds.Dispose();
return "<option value='-1'>-- Not Available --</option>";
}
foreach (DataRow dr in drs )
{
result.Append("<option value='" + dr[ "WC_ID" ] + "'>" + dr[ "WC" ] +
" : " + dr[ "WC_NAME" ] + "</option>");
}
return result.ToString();
}
.
.
.
"GetWCenterALL( String strArea )" method returns html options values to the user's browser.
And javascript function, "UpdateWC( result )" fills options and saves them in the dedicated
textbox( "txtWCValue" ). And when the dropdownlist filled by remotescript changes its selection,
its selected value is saved in the dedicated textbox( "txtWCSelect" ).
So options filled by remotescript and user's selection can be post-backed.
finally, the code-behind fills these post-backed values into to its original dropdownlist as follows.
. // in code-behind of my page.
.
.
private void DailyProdByWC_PreRender(object sender, System.EventArgs e)
{
this.ddlArea.Attributes.Add( "OnClick", "javascript:OnSelectedChange('ddlArea');" );
this.ddlWCenter.Attributes.Add( "OnClick", "javascript:OnSelectedChange('ddlWCenter');" );
.
.
.
.
this.SetDropDownList( this.ddlWCenter, this.txtWCValue.Text, this.txtWCSelect.Text );
}
/***********************************************************************
* Objective : method to set the options of dropdownlists with the post
* -backed option data.
* Param : DropDownList ddlSelect - Dropdownlist object to be set
* string strOptions - option strings
* string strSelect - selected value string
* Return : void
***********************************************************************/
private void SetDropDownList( DropDownList ddlSelect, string strOptions, string strSelect )
{
if( strOptions != "" )
{
ddlSelect.Items.Clear();
char[] chrdelim1 = {'<','>'};
char[] chrdelim2 = {'\''};
string[] strSect1 = strOptions.Split( chrdelim1 );
for( int i = 1 ; i < strSect1.Length ; i= i + 4)
{
string strValue = strSect1[ i ].Split( chrdelim2 )[ 1 ];
ddlSelect.Items.Add( new System.Web.UI.WebControls.ListItem( strSect1[ i+1 ], strValue ) );
}
if ( strSelect != "" )
ddlSelect.SelectedValue = strSelect;
}
}
Therefore, the code-behind can fills its values fiiled by remotescript. And the page can retain
its options and selected value.
In user's eyes, it's just refreshed!.
What a stupid manner it is!!!
p.s. I'm not good at writing and speaking english...
I know you'll understand...
If you know more better solution, let me know please.
I hate this method.
Jay
stupid developer....
|
|
|
|
|
hi..
can u plz make it little more clear?ie the situvation is i'm having 4 dropdown.make,segment,subsegmnet,product.On selecting make,values of corresponing make is to be filled in segement,on selecting a segment subsegment should fill with corresponding segment.. like wise up to product.On selecting Product i have to fill some textbox with values corresponding to tat product.some code in selected index change of product drop down.but the problem is that when i select a product all the other 3 dropdowns will loss the selected value...y???i think u got my problem...can u help me...?
thanking u
asha
|
|
|
|
|
Hello, I tried your component and I find it works fine, except the fact that, when saving back texts in non english languages, all special characters, like german umlauts, disappear.
I rewmember having had that problem long time ago in asp,but I don't remember how I solved that.
Do you have a hint ?
|
|
|
|
|
Hi,
the problem is due to a bug in rs.js. I had the same issue with french accents (eh eh those stranges languages...) and fixed it.
I emailed you the fixed version, normally you should already have received it. the problem is when using a GET method, the way of escaping those special characters is not done by the 'escape' function (like in the original code) but should be done by 'encodeURIcomponent' function.
Note also that you should be careful to try using POST method instead of the GET method cause it's more efficient (position RS.usePOST = true before using the RS object).
Have fun.
Regards.
Chic
|
|
|
|
|
thanks, it works ok for european characters - but unfortunately not for east asian characters, with which I am having to deal.
When I try to transmit strings containing thai or chinese characters, I get an error:
while invoking the remote method - input string was not in correct format
Maybe the author knows a solution ?
|
|
|
|
|
sorry, I was wrong - everything works perfect now, even with east asian characters. I don't know what happended before and finally I don't want to know....
UH
|
|
|
|
|
Why the page refresh when i do Remote scripting?
|
|
|
|
|
The page refresh when you click the submit button, but when you change the select make a Remote Scripting to fill the other
|
|
|
|
|
The page does not really refresh. What refreshes is hidden IFRAME element in the page which does a postback to the page with with the remote method. Unfortunately this cause the status bar to behave as if the whole page was refreshing when only the IFRAME is doing so.
Regards,
Alvaro
Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.
|
|
|
|
|
Hi,
I use your remotescripting blog. But sametime i receive this error message :
"'options' is null or not an object".
When i use script debugger, application stoped in rs.js, while rows.
RemoteScripting.prototype.ReplaceOptions = function(element, optionsHTML)
{
// Remove any existing options
while (element.options.length > 0)
element.options[0] = null;
In this state, element and options is null
have u ever received this message ??
Thanks
Mehmet
|
|
|
|
|
Hi Mehmet,
Make sure when you call ReplaceOptions that element is a valid object of type select . In other words, it must refer to an existing dropdown list in your form, otherwise you'll receive the error.
Regards,
Alvaro
Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.
|
|
|
|
|
I have this exception:
Message "No se puede encontrar el miembro."
StackTrace " at System.DefaultBinder.BindToMethod(BindingFlags bindingAttr, MethodBase[] match, Object[]& args, ParameterModifier[] modifiers, CultureInfo cultureInfo, String[] names, Object& state)\r\n at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)\r\n at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)\r\n at AMS.Web.RemoteScriptingClient.InvokeMethod() in c:\\documents and settings\\mllanos\\escritorio\\remotescriptingsourceandbinaries\\remotescripting\\remotescripting.cs:line 265"
Is this a bug? Thank you!
PD: Do you speak spanish???
Martín
|
|
|
|
|
Hola Martín,
This problem is caused when the remote method (or property) cannot be found. There may be several reasons:
1. The method has not been defined in your class (or control).
2. The method is not public .
3. The method's parameters are incompatible with the way it's being called by the client. Verify all the parameters are there, and they're all of type string .
Saludos,
Alvaro
Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.
|
|
|
|
|
we found this problem trying to test your examples, if you have any suggestion, becouse we didn't change the code, would be very helpfull.
Excuse my English
Isidoro
|
|
|
|
|
Hello Isidoro,
Please make sure you've downloaded the latest code and verify that the demo works on your server.
Regards,
Alvaro
Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.
|
|
|
|
|
Hi, I'm with Isidoro trying to understand why this example dont'n works as well as it works in your server.
We just make it works but when I change the first select, it throw this exception:
System.MissingMethodException: No se puede encontrar el miembro.
at System.DefaultBinder.BindToMethod(BindingFlags bindingAttr, MethodBase[] match, Object[]& args, ParameterModifier[] modifiers,
CultureInfo cultureInfo, String[] names, Object& state)
at System.RuntimeType.InvokeMember(String name, BindindgFlags invokeAttr, Binder binder, Object target, Object[] args,
ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target,
at AMS.Web.RemoteScriptingClient.InvokeMethod()
I click Acept and then it works well until I change the select again!
I hope you can help us!
Martín
|
|
|
|
|
I don't understand what the problem is. Is there a chance you can send me a copy of your project?
Thanks,
Alvaro
Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.
|
|
|
|
|
If you change the second parameter of the UpdateAmounts method to be a string rather than an int, then the problem goes away. The article mentions that the parameters of the remote method must be strings, but the sample has one of type int.
Hope this fixes your problem
J8B.
|
|
|
|
|
|
I'm sorry, but I hadn't realized that the demo still had a bug in it. I had submitted a fixed version to CodeProject a while back and thought they had updated it already. I never bother to download the code to verify it, and that's my fault.
Regards,
Alvaro
Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.
|
|
|
|
|
If the problem is that somebody "No se puede encontrar el miembro", well, I'd say that's not a bug, that's an extremely serious problem, and a doctor should be consulted inmediatelly
Alvaro, I have used the WebServices behavior with IExplorer and looks very easy to use (but is only for IExplorer). Have you evaluated it? How would it compare with RemoteScripting?
Best regards,
Julio
|
|
|
|
|
julio361 wrote:
If the problem is that somebody "No se puede encontrar el miembro", well, I'd say that's not a bug, that's an extremely serious problem, and a doctor should be consulted inmediatelly
Brings back memory of Lorena Bobbitt.
julio361 wrote:
Alvaro, I have used the WebServices behavior with IExplorer and looks very easy to use (but is only for IExplorer). Have you evaluated it? How would it compare with RemoteScripting?
I haven't actually. But I guess the greatest advantage of RemoteScripting is that it works across a variety of browsers. It's also pretty easy to use, I think.
Regards,
Alvaro
Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.
|
|
|
|
|
Hi,
First of all, thanks for the control. Very nice job.
I'm trying to use Remote Scripting with DotNetNuke, within an ASCX (module) file, to load a method from this control. But the methods are never executed, because the in the DNN exists only one web page that dinamically loads usercontrols.
Is it possible?
Thanks,
Catalin
|
|
|
|
|
Catalin MAICAN wrote:
First of all, thanks for the control. Very nice job.
Thanks!
Catalin MAICAN wrote:
I'm trying to use Remote Scripting with DotNetNuke, within an ASCX (module) file, to load a method from this control. But the methods are never executed, because the in the DNN exists only one web page that dinamically loads usercontrols.
Is it possible?
It should be. Simply call AMS.RemoteScripting.InvokeMethod after your user control has been loaded.
Regards,
Alvaro
Victory means exit strategy, and it's important for the President to explain to us what the exit strategy is. -- GWB, 1999.
|
|
|
|
|