how can I fill "MyUserName" on
<td width="18%" class="more"><div align="right">¿¿¿¿¿¿ </div></td>
<td width="82%">
<font color="#FFFFFF" face="MS Sans Serif, Tahoma, sans-serif">
<input type=text name="QTitle" size=51 maxlength=100 class=violet>
</font>
</td>
i try in c# but it not work please help
private void webBrowser2_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)
{
}
private void LoadProfileInformation()
{
DataSet dsNew = new DataSet();
//Some code to fetch information if you store it in a DB
//else you can put in static info if you may want.
//so you will nto need the dataset.
QTitle.Text = "MyUserName";
}
You can store it in the class then access it with code behinds like <%= myVar %> in your front end.
if you want to modify the values of divs on the front end then you need to use asp tags like
<asp:label runat="server" name="Qtitle"> </asp:label>
First of all you really need to think about moving to newer versions of XHTML/HTML! (I suggest you that because of your markup code).
In the other hand, in order to get your "QTitle" text set from server, you'll need to set "runat" attribute to "server" in your input, but, if you're using standard (X)HTML elements, you won't have such property "Text".
I suggest you to use a server control like TextBox which has the whole "Text" property:
<asp:TextBox ID="QTitle" runat="server" CssClass="Violet" />
Some server code-behind:
QTitle.Text = "Hello world";
Another suggestion is you won't be setting any property after PreRender ASP.NET Page life-cycle event.
Is the mark-up at the top of your question the resulting html or the source code for the form you are working with? If this is in-fact your asp.net form, try replacing the input tag with the following...
<asp:TextBox id="QTitle" runat="server" />
If the form is properly linked to the C# codebehind file you are using, QTitle.Text should now be accessible.
Related
I have a form that has a layout like so:
<cms:FormField runat="server" ID="fMemberType" Field="MemberType" />
<cms:FormField runat="server" ID="fEmployeeCount" Field="EmployeeCount" />
<asp:Literal runat="server" ID="test" Text="test" />
<script runat="server">
protected void Page_PreRender(object sender, EventArgs e)
{
test.Text = fMemberType.Value.ToString();
}
</script>
However this produces Object reference not set to an instance of an object. because it can't find fMemberType for some reason. Looking for the correct way of doing this.
It's worth noting that the form fields are dropdowns with depending flags set so changing them triggers a postback, or at least it would, but I set the webpart container to be an update panel so it's AJAXing which means the data isn't available in the page POST params. I could turn this off and grab the data from the POST data but wanted to know if there was a better way first.
So you're fully defining the fields and everything for your form? Why not use the DataForm control and dynamically create the form for you? You can then get the data like so: (formUserSettings is a cms:DataForm)
EditingFormControl ctrState = formUserSettings.BasicForm.FieldEditingControls["UserState"] as EditingFormControl;
Then do some checking and assign the value:
if (ctrState != null)
{
fState = ctrlState.Value;
}
Most likely the form value is not set until after the pre-render. Alen Genzic's recommendation will show that. May want to try OnInit.
I've duplicated the search box webpart so i can make changes. I'm trying to add a localization string to the placeholder attribute.
This isn't working:
<cms:CMSTextBox ID="txtWord" runat="server" EnableViewState="false" MaxLength="1000"
ProcessMacroSecurity="false" placeholder="<%= CMS.Helpers.ResHelper.GetString("kff.Search--PlaceHolderCopy")%>" />
nor does this:
<cms:CMSTextBox ID="txtWord" runat="server" EnableViewState="false" MaxLength="1000"
ProcessMacroSecurity="false" placeholder='<%= CMS.Helpers.ResHelper.GetString("kff.Search--PlaceHolderCopy")%>' />
I have a JS Snippet that does work, but i'm hoping to avoid copy in JS files.
var $searchField = $('.searchTextbox');
if ($('body').hasClass('ENCA')) {
// search field placeholder copy
$searchField.attr('placeholder', 'Search For Stuff');
}
else {
$searchField.attr('placeholder', 'Recherche');
}
Can I add the localization string to the server tag, or should it be done in the code behind. I'm not sure the best location in the code behind for this either, I can't see a Page_Load block.
You could add the following line in the SetupControl method in the codebehind:
txtWord.Attributes.Add("placeholder", ResHelper.GetString("kff.Search--PlaceHolderCopy"));
You cannot really use the <%= syntax to set properties of server-side controls.
Also, please note that the CMSTextBox control has a WatermarkText property, which might be what you are looking for. It uses the TextBoxWatermarkExtender control from the AjaxControlToolkit library.
There is no need to duplicate the webpart and have duplicate code just for something this simple. Just create a different webpart layout for that webpart and add the following code above the Panel:
<script runat="server">
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
txtWord.Attributes.Add("placeholder", ResHelper.GetString("yourstring"));
}
</script>
I have a special row in my table for errors:
<tr>
<td colspan="2"><p:message for="questionId" id="msgQuestion" /></td>
</tr>
How can I set this so the row is only displayed when there is an error?
In first place i will recommend not to use table to display layout elements
after that the ellement will apear even if the message is not present, if you are obliged to use it you can use som think like this in JS:
<script type="text/javascript">
window.onload = function() {
hideTdMessage();
};
hideTdMessage(){
var message = document.getElementById(msgQuestion);
if(message){
//the msg is present
}else{
//the msg is not present
}}
</script>
Or You can use your MBean to change the CSS class it's better than using JS.
But i will say that the best solution is not tu use the tabel.
Hope it helped
Use a JSF component and the property rendered
rendered="#{not empty facesContext.messageList}"
I want to get the value of the selected item of a radiobutton List using javascript.
My code is:
<asp:RadioButtonList runat="server" ID="Radio" RepeatColumns="3" CssClass="textfont">
<asp:ListItem Value="1" Selected="True">First</asp:ListItem>
<asp:ListItem Value="2">Second</asp:ListItem>
<asp:ListItem Value="3">Third</asp:ListItem>
</asp:RadioButtonList>
And this is my Javascript code:
<script type="text/javascript">
function sendParameters() {
var Id = '<%=HiddenField1.Value%>';
var ddl1 = document.getElementById("Radio").checked;
</script>
How to proceed?
First of all please view the source of the resulting web page and post the resulting radio button html. This will make it easier to answer because then the question comes down to plain HTML and jQuery.
The Reason is asp often changes the name of the ID, unless you add ClientIDMode="Static" to your control.
Once that is done this should do it:
var chosenValue = $('input:radio[id="Radio"]:checked').val();
alert(chosenValue);
Is there a way to dynamically set the ListId field in the ListView control. We cannot guarantee that the list we are interested in has a consistent GUID between installations (The list is deployed as part of a site template that we do not control). I've tried using the PreInit event to set a variable (see the list guid: section. If I remove the ListView tag, I see the proper GUID printed out. So I'm collecting the GUID correctly. However, The listview control errors out with the following message "Guid should contain 32 digits with 4 dashes". This tells me that the tag is not getting the variable set. Is this correct? Is there another way to specify the list to use?
Can this be done?
Sample code follows:
<%# Register TagPrefix="Sharepoint" ...details deleted.. %>
<br>
...stuff deleted.
<br>
<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
... more stuff deleted...
<p>list guid: <%=ListGuid %>
<Sharepoint:ListView ListId="<%=ListGuid %>" Enabled="true" runat="server" />
<p>
</asp:Content>
<script runat="server">
string ListGuid = string.Empty;
protected void Page_PreInit(object sender, EventArgs e)
{
SPSite Site = SPContext.Current.Site;
using (SPWeb HelpDesk = Site.OpenWeb("HelpDesk"))
{
SPList list = HelpDesk.Lists["Charge Numbers"];
ListGuid = list.ID.ToString();
}
}
</script>
Having server-side code like you do that gets injected into more server side code is a little weird and seems unlikely to work. What does the SharePoint log say about the list ID that it's trying to load? My guess is that it's not really trying to load the list represented by the GUID that you're setting in your ListGuid variable.
Instead of trying to force some global ListGuid variable to have the correct guid, why not just set the control's ListId property inside your application page's Load event handler?
In the aspx file:
<SharePoint:ListView Id="lv" runat="server" />
In the application page's codebehind:
protected ListView lv
In the Load event:
SPList list = HelpDesk.Lists["Charge Numbers"];
Guid myguid = list.ID;
lv.ListId = myguid.ToString();
I think the error message you are receiving is telling you what's going wrong... the ToString() is converting the GUID to an invalid format. There is an overload for the tostring
list.ID.ToString("N");
list.ID.ToString("D"); (this is the default)
list.ID.ToString("B");
list.ID.ToString("P");
... Try them all