PDA

View Full Version : [CLOSED] Parameter Problem in Ext.Net



vijay.sahu
Apr 04, 2013, 11:19 AM
Hi Danil,

We have Encountered a Problem several Times, When we pass some parameter from one method to another we several time get "comma" in prefix or suffix of parameter.

For Eg: The value of a parameter is '8,' or ',8'


The Approach is that I have got a value of one of the grid field in hidden field.
The Value of Hidden Field is tranfer on to Code page where we get above stated problems of "Comma" coming in prefix or suffix.


Approach:-

When Clicked on Grid -> Value gets Stored in Hidden Field ->Using Direct Method or Javascript Function we pass the value stored in Hidden Field as Parameter -> We now collect this parameter in our Method where we get comma in the prefix or suffix of value of parameter.

Even I would love to share the Code of the Problem on your demand.


Pls Share your inputs on this

Daniil
Apr 04, 2013, 1:06 PM
Hi @vijay.sahu,

Hard to say where those commas come from.

Yes, please provide a test case.

vijay.sahu
Apr 05, 2013, 5:51 AM
I have Used a Form Panel...
Inside a FormPanel there is a container which contains Grid..
As you can see, it also contains the hidden fields where it will get value from the store of Gridpanel

<ext:FormPanel runat="server" Border="false" ID="FormPanel1">
<FieldDefaults LabelAlign="Left" MsgTarget="Side" />
<Items>
<ext:Container ID="FormPanelUserAccount1" runat="server" Title="" Layout="HBoxLayout"
Border="false">
<Items>
<ext:Panel ID="pnl1" runat="server" Flex="45" Border="false">
<Items>
<ext:Hidden ID="hdnUserRoleId" Name="UserRoleId" runat="server" ClientIDMode="Static">
</ext:Hidden>
<ext:Hidden ID="hdnuroleid" Name="UserRoleId" runat="server" ClientIDMode="Static">
</ext:Hidden>
<ext:GridPanel ID="grdRoleMaster" runat="server" Title="" MarginSpec="5" Header="true">
<Store>
<ext:Store ID="StoreRoleMaster" runat="server" OnReadData="StoreRoleMaster_ReadData"
PageSize="10">
<Model>
<ext:Model ID="Model1" runat="server" IDProperty="UserRoleId">
<Fields>
<ext:ModelField Name="UserRoleId" />
<ext:ModelField Name="CountryId" />
<ext:ModelField Name="Name" />
<ext:ModelField Name="Description" />
<ext:ModelField Name="Status" />
<ext:ModelField Name="RowStatus" />
<ext:ModelField Name="CreatedBy" />
<ext:ModelField Name="CreatedDate" DateFormat="yyyy-MM-ddTHH:mm:ss" Type="Date" />
<ext:ModelField Name="CreatedIP" />
<ext:ModelField Name="ModifiedBy" />
<ext:ModelField Name="ModifiedDate" DateFormat="yyyy-MM-ddTHH:mm:ss" Type="Date" />
<ext:ModelField Name="ModifiedIP" />
</Fields>
</ext:Model>
</Model>
<Proxy>
<ext:PageProxy>
</ext:PageProxy>
</Proxy>
</ext:Store>
</Store>
<ColumnModel ID="CompanyColumnModel" runat="server">
<Columns>
<ext:Column ID="Name" runat="server" Text="User Account" DataIndex="Name" Flex="90" />
<ext:Column ID="Status" runat="server" Text="Status" DataIndex="Status" Enabled="false"
Align="Center" Flex="10">
<Renderer Handler="return (value) ? 'Active' : 'InActive'; ">
</Renderer>
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single" />
</SelectionModel>
<%--<DirectEvents>
<SelectionChange OnEvent="grdRoleMaster_SelectionChange" Before="return IsAddClick()" />
</DirectEvents>--%>
<Listeners>
<SelectionChange Handler="if (selected[0]) {
#{FormPanel1}.getForm().loadRecord(selected[0]); }; " />
</Listeners />


////////////////////////////////////////////////////////////////////////////////////////////////////////

Event

I have made an ajax call for this event.
//////////////////////////////////////////////////////////////////////////////////////////////////////////

private Paging<SelectAllUsersByRoleId_Result> BindUsersGrid(int start, int limit)
{

string[] words = hdnUserRoleId.Text.Split(','); ////Quick Watch Image Attched pls see the Image
hdnUserRoleId.Text = words[0];
Int64 userRoleId = Int64.Parse(string.IsNullOrEmpty(hdnUserRoleId.Tex t) ? "0" : hdnUserRoleId.Text);

if (objUserRoleMasterBAL == null) objUserRoleMasterBAL = new UserRoleMasterBAL();
List<SelectAllUsersByRoleId_Result> lstUsers = objUserRoleMasterBAL.SelectAllUsersByRole(userRole Id, CompanyId, (int)UserType.CompanyUser).OrderBy(o => o.Username).ToList();
int totalNumber = lstUsers.Count();
int numberToGet = (start + limit) > totalNumber ? (totalNumber - start) : limit;
if (numberToGet <= 0)
{
Paging2.MovePrevious();
}
return new Paging<SelectAllUsersByRoleId_Result>(lstUsers.GetRange(start, numberToGet), totalNumber);

}





pls see the two Images which I have attached for more details..

I have not uploaded the entire code as it would be really difficult for you to analyze it.59715972

Daniil
Apr 05, 2013, 8:35 AM
What is the content of hdnUserRoleId.Text?

string[] words = hdnUserRoleId.Text.Split(',');

vijay.sahu
Apr 05, 2013, 9:02 AM
The content for hdnUserRoleId.Text is of Integer Type which is followed by comma as i have shown in the previous Picture.


string[] words = hdnUserRoleId.Text.Split(',');

The above code I have written is so that I can get only the numeric value.

As shown in the Attached Image what I need is the value '1' and what I get is '1,'. Hence to get what I required I have to spilt that.

Pls see the Image for more Information

Vladimir
Apr 05, 2013, 10:16 AM
You have two hidden fields with same Name


<ext:Hidden ID="hdnUserRoleId" Name="UserRoleId" runat="server" ClientIDMode="Static">
</ext:Hidden>
<ext:Hidden ID="hdnuroleid" Name="UserRoleId" runat="server" ClientIDMode="Static">
</ext:Hidden>


ASP.NET combines values from fields with same name therefore you have comma

vijay.sahu
Apr 05, 2013, 10:27 AM
You have two hidden fields with same Name


<ext:Hidden ID="hdnUserRoleId" Name="UserRoleId" runat="server" ClientIDMode="Static">
</ext:Hidden>
<ext:Hidden ID="hdnuroleid" Name="UserRoleId" runat="server" ClientIDMode="Static">
</ext:Hidden>


ASP.NET combines values from fields with same name therefore you have comma

I tested it and it worked well
I realised my Mistake.
Thank You .
You can mark as closed.