|
I have a checkbox in my form. When the checkbox is checked , i want to fire a javascript which makes some controls as visible or not visible. I have writtent the code,but the javascript is not firing. Can anybody please help me on that? Am I doing something wrong here?
Following is my code:
<script type="text/javascript">
function SetCopyPermissionsControlState(panelControlId, checkBox) {
alert("hai");
var enabled = checkBox.checked;
var panelControl = document.getElementById(panelControl);
if (panelControl)
{
if (enabled)
{
panelControl.style.display = 'block';
}
else
{
panelControl.style.display = 'none';
}
}
<tr><td class="labeltext"><asp:CheckBox ID="chkCopyPermissions" runat="server" Text = "CopyPermissions;"
OnClick="SetCopyPermissionsControlState(CopyPermissionsPanel,this)" /></td>
<td><asp:Label ID="lblCopyPermissionMessage" runat="server" ></asp:Label></td>
</tr>
<tr>
<asp:Panel ID = "CopyPermissionsPanel" runat = "server" Visible="false">
<td class="labeltext"><asp:Label ID = "lblCopyPermissions" runat = "server" Text = "Existing UserName" ></asp:Label></td>
<td><asp:TextBox id = "ExistingLoginTextBox" runat="server" TextMode="SingleLine" MaxLength="50"></asp:TextBox>
<asp:Button ID = "CopyPermissionsButton" runat="server" Text="Copy" OnClick="CopyPermissionsButton_Click" />
</td>
</asp:Panel>
</tr>
Please help.
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
var panelControl = document.getElementById(panelControl);
Please pass the actual proper id to the method. I guess it should be panelControlId
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
meeram395 wrote: var panelControl = document.getElementById(panelControl);
Shouldn't this be var panelControl = document.getElementById(panelControlId); ?
meeram395 wrote: OnClick="SetCopyPermissionsControlState(CopyPermissionsPanel,this)"
Don't you need a single quote (')? OnClick="SetCopyPermissionsControlState('CopyPermissionsPanel',this)
When you are using server control id in JS, best practice is to use ClientId . Your code will break if you plan to make the panel as a child of some other container control because ASP.NET will change the name when it render the control.
|
|
|
|
|
ok. thanks. now the javascript is firing. but the panelcontrolid is firing. I opened View-->Source, but couldn't find the control asp panel. what could be the issue? Any guess?
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
meeram395 wrote: but the panelcontrolid is firing.
What do you mean?
meeram395 wrote: I opened View-->Source, but couldn't find the control asp panel. what could be the issue?
Browsers only understand HTML. ASP.NET will convert ASP:Panel to HTML DIV (not sure) when it is rendering the page. So you don't see ASP:Panel in the view source.
|
|
|
|
|
I have removed the panel control and I put an id to row.Now it is working fine. Following is the codew:
<tr><td class="labeltext"><asp:CheckBox ID="chkCopyPermissions" runat="server" Text = "CopyPermissions"
OnClick="SetCopyPermissionsControlState('CopyPermissionsRow',this)" /></td>
<td><asp:Label ID="lblCopyPermissionMessage" runat="server" ></asp:Label></td>
</tr>
<tr id="CopyPermissionsRow" visible="false">
<td class="labeltext">
<asp:Label ID = "lblCopyPermissions" runat = "server" Text = "Existing UserName" ></asp:Label>
</td>
<td>
<asp:TextBox id = "ExistingLoginTextBox" runat="server" TextMode="SingleLine" MaxLength="50"></asp:TextBox>
<asp:Button ID = "CopyPermissionsButton" runat="server" Text="Copy" OnClick="CopyPermissionsButton_Click" />
</td>
</tr>
Because of the above change, the javascript function , SetCopyPermissionsControlState, is firing now. But the issue is, I made it visible=false when the page loads which is not happening. The page loads by displaying the controls. However, when I check the checkboxes, it is changing accordingly. Any idea why it is not happening for the first time?
I don't want postback, because there is a password textbox in the form which erases the value on postback.
Following is my javascript function:
function SetCopyPermissionsControlState(rowControlId, checkBox) {
var enabled = checkBox.checked;
alert("enabled" + enabled);
var rowControl = document.getElementById(rowControlId);
alert("panelControl" + rowControl);
if (rowControl)
{
if (enabled)
{
rowControl.style.display = '';
}
else
{
rowControl.style.display = 'none';
}
}
}
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
try to make auto post back property = true;
|
|
|
|
|
I don't want autopostback property to true, since there is a password textbox in the page which is losing value on postback. so everytime there is a postback, the user has to retype which is quite cumbersome.
Is there any other way?
Success is the good fortune that comes from aspiration, desperation, perspiration and inspiration.
|
|
|
|
|
In the HTML I have -
<%#ShowProjectUrl(Eval("website_url").ToString())%>
In the code behind I have -
protected string ShowProjectUrl(string projectUrl)
{
if (projectUrl != String.Empty)
return "<br />Project URL - <a href='" + projectUrl + "' target='_blank'>" + projectUrl + "</a><br /><br />";
else
return String.Empty;
}
The website is stored in the DB as www.XXX.com and passes to the function OK.
But when I click on the hyperlink at run time it navigates to -
http://localhost/www.XXX.com
If anyone know hoe to get rid of the localhost, it would be most appreciated.
Thanks.
|
|
|
|
|
u should plus http://www.xxx.com
going like dis
return "<br />Project URL - <a href='http://" + projectUrl + "' target='_blank'>" + projectUrl + "</a><br /><br />";
|
|
|
|
|
Thank you very much, that has worked!
|
|
|
|
|
hihi welcome.. n gud luck =D
|
|
|
|
|
hi all
Im using Ajax timer for web site asynchronously loads some details, so when i click one of that item sometimes it display this error,im not using any Resonse.Write().
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '
<!DOCTYPE html PUB'.
Pls help me solve this , this is bit urgent
Thanks
|
|
|
|
|
Can you show the server side code?
|
|
|
|
|
anyone know how to use this file?
i already create 1 resx file in my webcontrol project.. then i put javascript in this res.
then i want to register js file into my page using dis..
Me.Page.ClientScript.RegisterClientScriptResource(GetType(ScriptsManager), "MyControl.prototype.js")
MyControl = my namespace
prototype.js = my js file
ScriptsManager = my Public Class
but output say :
<script src="/ReMS_V2/WebResource.axd?d=loL1DUSbq11mfdlYGrmMGW-hYUrL63jxbEa6WSRmzFC2sNXk2_iY9ZAY8UffrfgR0&t=633828149324159480" type="text/javascript"></script>
n still error coz file note found..
i'm using asp.net vb language..
anyone can help me? plz...
modified on Friday, July 10, 2009 2:46 AM
|
|
|
|
|
syaiful_86 wrote: i already create 1 resx file in my webcontrol project.. then i put javascript in this res.
Not sure resx files can be used to put JS. They are mostly used to create localizable applications. Here[^] is a quick start article.
Are you trying to embed JS with your web control? If yes, read this[^] article. I have explained the tricks to embed JS in that article.
|
|
|
|
|
|
syaiful_86 wrote: "System.Web.UI.WebControls.headerbg.gif" = must be declare 1st like this
[assembly: System.Web.UI.WebResource ("System.Web.UI.WebControls.headerbg.gif",
"text/js", PerformSubstitution = true)] or not?
That code shows embedding the image into the assembly. I'd suggest to download the code provided with that article. Try to create a simple control by referring that code. If everything is OK, move that to your main project.
Read MSDN documentation about the methods used. It will help you to get started.
|
|
|
|
|
Hi.. thanks.. but still cannot..
maybe i dun understand
can u help me xplain this
Me.Page.ClientScript.RegisterClientScriptResource(Me.GetType, "MyControl.Resources.Myjs.js")
Me.GetType
-what type we should put in? class type? control type?
"MyControl.Resources.Myjs.js"
-MyControl mean assembly name? name space?
-Resources how we get dis?
-Myjs.jswe should put file name izit?
|
|
|
|
|
syaiful_86 wrote: -what type we should put in? class type? control type?
It can be any type. Me.GetType should do.
syaiful_86 wrote: "MyControl.Resources.Myjs.js"
-MyControl mean assembly name? name space?
You need fully qualified path which starts from the namespace name.
syaiful_86 wrote: -Myjs.jswe should put file name izit?
Yes. You need your file name here. MSDN[^] has an example which will get you started.
|
|
|
|
|
YeahHHh.. Done Already Thank Q sooOooo MuuuuChh
|
|
|
|
|
Is there a way to define a sitemap in your masterpage and only show childnodes based on what page you're on? What is the best to accomplish something like this? TreeView? Menu? Repeater?
Example:
Products.aspx has a left nav displaying
Products
Product1
Product2
Services
Services.aspx has a left nav displaying
Products
Services
Service1
Service2
Thanks in advance!
|
|
|
|
|
I have a multiselect listbox that sends selections to the database field separated by commas - no problem there. No problem displaying the data.
I need to allow folks to edit the form data so I have a formview with all fields bound but when I try to bind the multiselect listbox, I get an error (because the data does not match the listbox items) -
So, I put the data into an array, intending to use the array values to set the selected items in the listbox. But I am a long time asp coder and cannot get my brain around how to do this with asp.net (VB)... I'm sure that I need to loop through the array values and compare them to the listbox values (loop within loop...)
I cannot believe I am the only one out there who has had to set the selections of a listbox this way...
Any help is MOST appreciated. This rediculous issue is holding up my entire project.....
Thanks
ublend
|
|
|
|
|
Just to get you started i would give you the logic to be implemented.
You need a nested for loop, the outer loop spanning the length equal to the master data size while the inner loop spanning the length of the array obtained by splitting up the delimited values. Later you just need to check the value of the outer loop and the inner loop and if the match is found, mark the outer loop item as selected.
Hope this helps.
When you fail to plan, you are planning to fail.
|
|
|
|
|
thanks for the reply - I found that I was making it way too complicated...
Condango had the solution:
to highlight from database to multiselect
where SelectedDisplayValue is the value from database(eg SelectedDisplayValue= 3,4,10)
For i = 0 To (objListbox.Items.Count - 1)
If InStr(SelectedDisplayValue, objListbox.Items(i).Value) Then
objListbox.Items(i).Selected = True
End If
Next
ublend
|
|
|
|